onlyoffice / docs-integration-sdk-java Goto Github PK
View Code? Open in Web Editor NEWSDK for integrating ONLYOFFICE Document Server into your own website or application on Java
License: Apache License 2.0
SDK for integrating ONLYOFFICE Document Server into your own website or application on Java
License: Apache License 2.0
Sorry I must be really stupid can you give me an example on how to use convertService ? I don't quite understand how to set the stream/byte array/file to convert in the call.
I wanted to avoid having onlyoffice download the file from a url and pass the file stream directly to it. Is this possible ?
Here my full example:
private void transformWithSDK(final String sourceMimetype, final String targetMimetype, final Map<String, String> parameters,
final File sourceFile, final File targetFile, TransformManager transformManager) throws Exception
{
logger.info("START TRANSFORMER SDK '"+this.getClass().getSimpleName());
String extensionSource = FilenameUtils.getExtension(sourceFile.getName());
String extensionTarget = FilenameUtils.getExtension(targetFile.getName());
String srcType = extensionSource;
String outType = extensionTarget;
String url = urlManager.getInnerDocumentServerUrl();
Security security = Security.builder()
.key(settingsManager.getSecurityKey())
.header(settingsManager.getSecurityHeader())
.prefix(settingsManager.getSecurityPrefix())
.build();
HttpClientSettings httpClientSettings = HttpClientSettings.builder()
.ignoreSSLCertificate(settingsManager.isIgnoreSSLCertificate())
.build();
String convertServiceUrl = settingsManager.getDocsIntegrationSdkProperties()
.getDocumentServer()
.getConvertService()
.getUrl();
ConvertRequest convertRequest = ConvertRequest.builder()
.async(false)
.filetype(srcType) // txt
.outputtype(outType) // docx
.key(new SimpleDateFormat("MMddyyyyHHmmss").format(new Date()))
.url(sourceFile.toURI().toURL().toString()) // ????? I MUS CREATE A GET SERVICE FOR ONLYOFFICE ???
.build();
requestManager.executePostRequest(
urlManager.sanitizeUrl(url) + convertServiceUrl,
convertRequest,
security,
httpClientSettings,
new RequestManager.Callback< ValidationResult>() {
public ValidationResult doWork(final Object response) throws Exception {
String content = IOUtils.toString(((HttpEntity) response).getContent(), "utf-8").trim();
JSONObject result = new JSONObject(content);
if (result.has("error")) {
Integer errorCode = result.getInt("error");
return ValidationResult.builder()
.status(Status.FAILED)
.error(ConvertResponse.Error.valueOfCode(errorCode))
.build();
}
String fileUrl = result.getString("fileUrl");
return requestManager.executeGetRequest(
fileUrl,
httpClientSettings,
new RequestManager.Callback<ValidationResult>() {
@Override
public ValidationResult doWork(final Object response) throws IOException {
byte[] bytes = EntityUtils.toByteArray((HttpEntity) response);
if (bytes.length > 0) {
FileUtils.writeByteArrayToFile(targetFile, bytes);
return ValidationResult.builder()
.status(Status.SUCCESS)
.build();
} else {
return ValidationResult.builder()
.status(Status.FAILED)
.error(CommonResponse.Error.DOWNLOAD_RESULT)
.build();
}
}
});
}
});
logger.info("END TRANSFORMER SDK '"+this.getClass().getSimpleName());
}
I am starting to work with oforms and would like to use the service of “SetFormValue” to fill the values of an oform with a map of values.
Is it possible to add a manager class to support this kind of operation with the oform ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.