Skip to content

Commit 48d5b93

Browse files
package 20.7.0
1 parent 0a8a344 commit 48d5b93

File tree

257 files changed

+11015
-54505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+11015
-54505
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ hs_err_pid*
1515
**/target
1616
target
1717
build
18-
testresult
18+
testresult/*.*

.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>aspose-cloud-html</name>
3+
<name>aspose-html-cloud</name>
44
<comment></comment>
55
<projects>
66
</projects>

README.md

Lines changed: 178 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,87 +13,153 @@ Building the API client library requires [Maven](https://maven.apache.org/) to b
1313
To use Aspose HTML for Cloud SDK you need to register an account with [Aspose Cloud](https://www.aspose.cloud/) and lookup/create App Key and SID at [Cloud Dashboard](https://dashboard.aspose.cloud/#/apps). There is free quota available. For more details, see [Aspose Cloud Pricing](https://purchase.aspose.cloud/pricing).
1414

1515
## Installation
16-
To install the API client library to your local Maven repository, simply execute:
17-
18-
```shell
19-
mvn install
20-
```
21-
22-
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
23-
24-
```shell
25-
mvn deploy
26-
```
27-
28-
Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.
2916

17+
Get ready package or build from source.
3018
### Maven users
3119
Add this dependency to your project's POM:
3220

3321
```xml
34-
<dependency>
35-
<groupId>com.aspose</groupId>
36-
<artifactId>aspose-html-cloud</artifactId>
37-
<version>19.5.0</version>
38-
<scope>compile</scope>
39-
</dependency>
22+
<repositories>
23+
...
24+
<repository>
25+
<id>AsposeJavaAPI</id>
26+
<name>Aspose Java API</name>
27+
<url>https://repository.aspose.cloud/repo/</url>
28+
</repository>
29+
...
30+
</repositories>
31+
32+
<dependencies>
33+
...
34+
<dependency>
35+
<groupId>com.aspose</groupId>
36+
<artifactId>aspose-html-cloud</artifactId>
37+
<version>20.7.0</version>
38+
<scope>compile</scope>
39+
</dependency>
40+
...
41+
</dependencies>
4042
```
4143

42-
### Others
43-
44-
At first generate the JAR by executing:
45-
46-
mvn package -DskipTests
47-
48-
Then manually install the following JARs:
49-
50-
* target/aspose-html-cloud-19.5.0.jar
51-
* target/lib/*.jar
5244

5345
### Sample usage
5446
```java
55-
import com.aspose.html.client.invoker.*;
56-
import com.aspose.html.client.invoker.auth.*;
57-
import com.aspose.html.client.api.ConversionApi;
47+
package com.aspose.test_package;
5848

5949
import java.io.File;
60-
import java.util.*;
50+
import java.io.FileOutputStream;
51+
import java.io.IOException;
52+
import java.io.InputStream;
53+
import java.io.OutputStream;
54+
import com.aspose.html.ApiClient;
55+
import com.aspose.html.Configuration;
56+
import com.aspose.html.api.ConversionApi;
57+
import com.aspose.html.api.StorageApi;
58+
import com.aspose.html.model.FilesUploadResult;
59+
import okhttp3.MediaType;
60+
import okhttp3.MultipartBody;
61+
import okhttp3.RequestBody;
62+
import okhttp3.ResponseBody;
63+
import retrofit2.Call;
64+
import retrofit2.Response;
65+
66+
public class App {
67+
68+
// Helper method save the response body to the destination directory
69+
public static long saveToDisc(ResponseBody body, String fileName) {
70+
71+
File savedFile = new File(Configuration.getTestDstDir() + File.separator + fileName);
72+
long fileSizeDownloaded = 0;
73+
74+
try (InputStream inputStream = body.byteStream();
75+
OutputStream outputStream = new FileOutputStream(savedFile))
76+
{
77+
byte[] fileReader = new byte[4096];
78+
79+
while (true) {
80+
int read = inputStream.read(fileReader);
81+
if (read == -1) break;
82+
83+
outputStream.write(fileReader, 0, read);
84+
fileSizeDownloaded += read;
85+
}
86+
outputStream.flush();
87+
} catch (Exception e) {
88+
e.printStackTrace();
89+
}
90+
return fileSizeDownloaded;
91+
}
6192

62-
public class ConversionApiExample {
93+
6394

6495
public static void main(String[] args) {
96+
97+
// Get keys from aspose site.
98+
// There is free quota available.
99+
// For more details, see https://purchase.aspose.cloud/pricing
65100

66101
Configuration.setAPI_KEY("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
67102
Configuration.setAPP_SID("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
68103
Configuration.setBasePath("https://api.aspose.cloud/v3.0");
69104
Configuration.setAuthPath("https://api.aspose.cloud/connect/token");
70105
Configuration.setUserAgent("WebKit");
71106
Configuration.setDebug(true);
107+
Configuration.setTestSrcDir("testdata");
108+
Configuration.setTestDstDir("testresult");
109+
110+
String name = "test.html";// Document name. Place the html document in the folder "testdata".
111+
String outFormat = "jpg"; // Convert to jpg
112+
Integer width = 800; // Resulting image width.
113+
Integer height = 1000; // Resulting image height.
114+
Integer leftMargin = 10; // Left resulting image margin.
115+
Integer rightMargin = 10; // Right resulting image margin.
116+
Integer topMargin = 10; // Top resulting image margin.
117+
Integer bottomMargin = 10; // Bottom resulting image margin.
118+
Integer resolution = 300; // Resolution of resulting image.
119+
String folder = "/"; // The folder in the storage. Should exist.
120+
String storage = null; // Name of the storage. null
121+
122+
// Creating API for need operations
123+
ConversionApi conversionApi = new ApiClient().createService(ConversionApi.class);
124+
StorageApi storageApi = new ApiClient().createService(StorageApi.class);
125+
72126

73-
ConversionApi api = new ApiClient().createService(ConversionApi.class);
74-
75-
String name = "name_example.html"; // String | Document name.
76-
String outFormat = "jpg"; // String | Resulting image format.
77-
Integer width = 800; // Integer | Resulting image width.
78-
Integer height = 1000; // Integer | Resulting image height.
79-
Integer leftMargin = 10; // Integer | Left resulting image margin.
80-
Integer rightMargin = 10; // Integer | Right resulting image margin.
81-
Integer topMargin = 10; // Integer | Top resulting image margin.
82-
Integer bottomMargin = 10; // Integer | Bottom resulting image margin.
83-
Integer resolution = 300; // Integer | Resolution of resulting image.
84-
String folder = "folder_example"; // String | The document folder.
85-
String storage = "storage_example"; // String | The document storage.
86127
try {
87-
File result = apiInstance.GetConvertDocumentToImage(name, outFormat, width, height, leftMargin, rightMargin, topMargin, bottomMargin, resolution, folder, storage);
88-
89-
//Save to test directory
90-
File copyFile = new File("~/testdir/test.zip");
91-
result.renameTo(copyFile);
92-
} catch (ApiException e) {
93-
System.err.println("Exception when calling ConversionApi#GetConvertDocumentToImage");
94-
e.printStackTrace();
95-
}
96-
}
128+
129+
// Upload file to storage
130+
// Test file in the "/testdata" folder in the root of the project
131+
File f = new File(Configuration.getTestSrcDir(), name);
132+
133+
if(!f.exists()) {
134+
System.out.println("file not found");
135+
throw new RuntimeException("Test file not found");
136+
}
137+
138+
RequestBody requestBody = RequestBody.create( MediaType.parse("multipart/form-data"), f);
139+
MultipartBody.Part fileToUpload = MultipartBody.Part.createFormData("file", f.getName(), requestBody);
140+
141+
// Upload document to storage
142+
Call<FilesUploadResult> callUpload = storageApi.uploadFile(folder + File.separator + name, fileToUpload, null);
143+
Response<FilesUploadResult> res = callUpload.execute();
144+
System.out.println("Executed is successful = " + res.isSuccessful());
145+
146+
// Prepare call execute
147+
Call<ResponseBody> call = conversionApi.GetConvertDocumentToImage(name, outFormat, width, height, leftMargin, rightMargin, topMargin, bottomMargin, resolution, folder, storage);
148+
149+
// Execute request
150+
Response<ResponseBody> img = call.execute();
151+
152+
// Get body from response
153+
ResponseBody answer = img.body();
154+
155+
// Save to test directory
156+
long result = saveToDisc(answer, "test.zip");
157+
System.out.println("Result size = " + result);
158+
159+
} catch (IOException e) {
160+
e.printStackTrace();
161+
}
162+
}
97163
}
98164
```
99165

@@ -124,13 +190,15 @@ Method | HTTP request | Description
124190
**PostConvertDocumentInRequestToMarkdown** | **POST** /html/convert/md | Converts the HTML document (in request content) to Markdown and uploads resulting file to storage by specified path.
125191
**PutConvertDocumentToMarkdown** | **PUT** /html/{name}/convert/md | Converts the HTML document (located on storage) to Markdown and uploads resulting file to storage by specified path.
126192

193+
127194
## ImportApi
128195
Method | HTTP request | Description
129196
------------- | ------------- | -------------
130197
**GetConvertMarkdownToHtml** | **GET** /html/{name}/import/md | Converts the Markdown document (located on storage) to HTML and returns resulting file in response content.
131198
**PostConvertMarkdownInRequestToHtml** | **POST** /html/{name}/import/md | Converts the Markdown document (in request content) to HTML and uploads resulting file to storage by specified path.
132199
**PutConvertMarkdownToHtml** | **PUT** /html/import/md | Converts the Markdown document (located on storage) to HTML and uploads resulting file to storage by specified path.
133200

201+
134202
## DocumentApi
135203
Method | HTTP request | Description
136204
------------- | ------------- | -------------
@@ -142,17 +210,69 @@ Method | HTTP request | Description
142210
**GetDocumentImages** | **GET** html/{name}/images/all | Return all HTML document images packaged as a ZIP archive.
143211
**GetDocumentImagesByUrl** | **GET** html/images/all | Return all HTML page images packaged as a ZIP archive by the source page URL.
144212

213+
145214
## TemplateMergeApi
146215
Method | HTTP request | Description
147216
------------- | ------------- | -------------
148217
**GetMergeHtmlTemplate** | **GET** /html/{templateName}/merge | Populate HTML document template with data located as a file in the storage.
149218
**PostMergeHtmlTemplate** | **POST** /html/{templateName}/merge | Populate HTML document template with data from the request body. Result document will be saved to storage.
150219

151220

221+
## SeoApi
222+
Method | HTTP request | Description
223+
------------- | ------------- | -------------
224+
**GetSeoWarning** | **GET** /html/seo | Page analysis and return of SEO warnings.
225+
**GetHtmlWarning** | **GET** /html/validator | Checks the markup validity of Web documents in HTML, XHTML, etc.
226+
227+
228+
## StorageApi
229+
Method | HTTP request | Description
230+
------------- | ------------- | -------------
231+
**downloadFile** | **GET** /html/storage/file/{path} | Download file from storage.
232+
**uploadFile** | **PUT** /html/storage/file/{path} | Upload file to storage.
233+
**moveFile** | **PUT** /html/storage/file/move/{srcPath} | Move file in storage.
234+
**deleteFile** | **DELETE** /html/storage/file/{path} | Delete file in the storage.
235+
**createFolder** | **PUT** /html/storage/folder/{path} | Create the folder in the storage.
236+
**moveFolder** | **PUT** /html/storage/folder/move/{srcPath} | Move folder in the storage.
237+
**deleteFolder** | **DELETE** /html/storage/folder/{path} | Delete folder in the storage.
238+
**getFilesList** | **GET** /html/storage/folder/{path} | Get all files and folders within a folder.
239+
**getDiscUsage** | **GET** /html/storage/disc | Get disc usage in the storage.
240+
**objectExists** | **GET** /html/storage/exist/{path} | Check if file or folder exists.
241+
**storageExists** | **GET** /html/storage/{storageName}/exist | Check if storage exists.
242+
**getFileVersions** | **GET** /html/storage/version/{path} | Get file versions in the storage.
243+
244+
245+
## Build from source
246+
To install the API client library to your local Maven repository, simply execute from root of the git folder:
247+
248+
```shell
249+
mvn install -DskipTests
250+
```
251+
252+
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
253+
254+
```shell
255+
mvn deploy
256+
```
257+
258+
Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.
259+
260+
### Others
261+
262+
At first generate the JAR by executing:
263+
264+
mvn package -DskipTests
265+
266+
Then manually install the following JARs:
267+
268+
* target/aspose-html-cloud-20.7.0.jar
269+
* target/lib/*.jar
270+
152271
## Recommendation
153272
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
154273

274+
155275
### Examples
156276
[Tests](./src/test/java/com/aspose/html/client/api) contain various examples of using the Aspose.HTML SDK.
157277

158-
[Docs](./doc/) Full javadoc for Aspose.HTML Api SDK
278+
[Docs](./doc/) Full javadoc for Aspose.HTML Api SDK in html format.

doc/META-INF/MANIFEST.MF

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Manifest-Version: 1.0
2+
Built-By: Alexander Makogon
3+
Created-By: Apache Maven 3.6.3
4+
Build-Jdk: 1.8.0_202
5+

0 commit comments

Comments
 (0)