Skip to content

Commit cfa4c45

Browse files
update file parameters
1 parent 346e5a8 commit cfa4c45

File tree

398 files changed

+2060
-3167
lines changed

Some content is hidden

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

398 files changed

+2060
-3167
lines changed

src/main/java/com/aspose/words/cloud/ApiCallback.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
package com.aspose.words.cloud;
2929

30-
import java.io.IOException;
31-
3230
import java.util.Map;
3331
import java.util.List;
3432

src/main/java/com/aspose/words/cloud/ApiClient.java

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
*/
2727
package com.aspose.words.cloud;
2828

29-
import com.google.gson.JsonElement;
30-
import com.google.gson.JsonObject;
31-
import com.google.gson.JsonParser;
3229
import com.squareup.okhttp.*;
3330
import com.squareup.okhttp.internal.http.HttpMethod;
3431
import com.squareup.okhttp.logging.HttpLoggingInterceptor;
@@ -37,29 +34,11 @@
3734
import okio.Okio;
3835
import org.threeten.bp.LocalDate;
3936
import org.threeten.bp.OffsetDateTime;
40-
import org.threeten.bp.format.DateTimeFormatter;
41-
42-
import javax.net.ssl.*;
43-
44-
import java.io.Console;
45-
import java.io.File;
46-
import java.io.IOException;
47-
import java.io.InputStream;
48-
import java.io.UnsupportedEncodingException;
49-
import java.lang.reflect.Field;
50-
import java.lang.reflect.Method;
51-
import java.lang.reflect.ParameterizedType;
37+
38+
import java.io.*;
5239
import java.lang.reflect.Type;
5340
import java.net.URLConnection;
5441
import java.net.URLEncoder;
55-
import java.security.GeneralSecurityException;
56-
import java.security.KeyStore;
57-
import java.security.SecureRandom;
58-
import java.security.cert.Certificate;
59-
import java.security.cert.CertificateException;
60-
import java.security.cert.CertificateFactory;
61-
import java.security.cert.X509Certificate;
62-
import java.text.DateFormat;
6342
import java.util.*;
6443
import java.util.Map.Entry;
6544
import java.util.concurrent.TimeUnit;
@@ -71,7 +50,7 @@ public class ApiClient {
7150
private String apiVersion = "v4.0";
7251
private String baseUrl = "https://api.aspose.cloud";
7352
private String basePath = baseUrl + "/" + apiVersion;
74-
private String clientVersion = "19.10.0";
53+
private String clientVersion = "20.3.0";
7554
private boolean debugging = false;
7655
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
7756
private String tempFolderPath = null;
@@ -85,6 +64,15 @@ public class ApiClient {
8564
private String refreshToken;
8665
private String appKey;
8766
private String appSid;
67+
68+
public ApiClient(String appSid, String appKey, String baseUrl) {
69+
this();
70+
this.appSid = appSid;
71+
this.appKey = appKey;
72+
if (baseUrl != null) {
73+
this.setBaseUrl(baseUrl);
74+
}
75+
}
8876

8977
/*
9078
* Constructor for ApiClient
@@ -194,7 +182,7 @@ public ApiClient setBaseUrl(String baseUrl) {
194182
*/
195183
public ApiClient setBasePath(String basePath) {
196184
this.basePath = basePath;
197-
this.baseUrl = basePath.replace("/v4.0", "");
185+
this.baseUrl = basePath.replace("/v1.1", "").replace("/v1", "").replace("/v2", "").replace("/v3", "");
198186
return this;
199187
}
200188

@@ -893,7 +881,7 @@ public <T> T handleResponse(Response response, Type returnType) throws ApiExcept
893881
* @return The HTTP call
894882
* @throws ApiException If fail to serialize the request body object
895883
*/
896-
public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
884+
public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException, IOException {
897885
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener);
898886

899887
return httpClient.newCall(request);
@@ -914,7 +902,7 @@ public Call buildCall(String path, String method, List<Pair> queryParams, List<P
914902
* @return The HTTP request
915903
* @throws ApiException If fail to serialize the request body object
916904
*/
917-
public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
905+
public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException, IOException {
918906
addOAuthAuthentication(headerParams);
919907
final String url = buildUrl(path, queryParams, collectionQueryParams);
920908
final Request.Builder reqBuilder = new Request.Builder().url(url);
@@ -1052,12 +1040,12 @@ public RequestBody buildRequestBodyFormEncoding(Map<String, Object> formParams)
10521040
* @param formParams Form parameters in the form of Map
10531041
* @return RequestBody
10541042
*/
1055-
public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) {
1043+
public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) throws IOException {
10561044
MultipartBuilder mpBuilder = new MultipartBuilder().type(MultipartBuilder.FORM);
10571045
for (Entry<String, Object> param : formParams.entrySet()) {
1058-
if (param.getValue() instanceof File) {
1059-
File file = (File) param.getValue();
1060-
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\"");
1046+
if (param.getValue() instanceof byte[]) {
1047+
byte[] file = (byte[]) param.getValue();
1048+
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + param.getKey() + "\"");
10611049
MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file));
10621050
mpBuilder.addPart(partHeaders, RequestBody.create(mediaType, file));
10631051
}
@@ -1075,8 +1063,8 @@ public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) {
10751063
* @param file The given file
10761064
* @return The guessed Content-Type
10771065
*/
1078-
public String guessContentTypeFromFile(File file) {
1079-
String contentType = URLConnection.guessContentTypeFromName(file.getName());
1066+
public String guessContentTypeFromFile(byte[] file) throws IOException {
1067+
String contentType = URLConnection.guessContentTypeFromStream(new ByteArrayInputStream(file));
10801068
if (contentType == null) {
10811069
return "application/octet-stream";
10821070
}
@@ -1087,7 +1075,7 @@ public String guessContentTypeFromFile(File file) {
10871075

10881076
/**
10891077
* Request OAuth token
1090-
* @throws ApiException If fails to authorize
1078+
@throw ApiException If authorization is failed
10911079
*/
10921080
public void requestToken() throws ApiException {
10931081
try {
@@ -1131,6 +1119,5 @@ private void addOAuthAuthentication(Map<String, String> headerParams) throws Api
11311119
*/
11321120
private class GetAccessTokenResult {
11331121
public String access_token;
1134-
public String refresh_token;
11351122
}
11361123
}

src/main/java/com/aspose/words/cloud/ApiException.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ public ApiException(int code, String message, Map<String, List<String>> response
8585
}
8686

8787
private void setInnerError() {
88-
if (!responseBody.startsWith("{")) return;
88+
if (!responseBody.contains("Error") || !responseBody.startsWith("{")) return;
8989
JsonElement elem = new JsonParser().parse(responseBody);
9090
this.innerError = new JSON().deserialize(
91-
elem.getAsJsonObject().get("Error").toString(),
92-
ApiError.class);
91+
elem.getAsJsonObject().get("Error").toString(),
92+
ApiError.class);
9393
}
94+
9495
/**
9596
* Get the HTTP status code.
9697
*

src/main/java/com/aspose/words/cloud/JSON.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import com.google.gson.stream.JsonWriter;
3737
import com.google.gson.JsonElement;
3838
import io.gsonfire.GsonFireBuilder;
39-
import io.gsonfire.TypeSelector;
4039
import org.threeten.bp.LocalDate;
4140
import org.threeten.bp.OffsetDateTime;
4241
import org.threeten.bp.ZoneOffset;
@@ -51,12 +50,8 @@
5150
import java.text.DateFormat;
5251
import java.text.ParseException;
5352
import java.text.ParsePosition;
54-
import java.text.SimpleDateFormat;
55-
import java.util.Calendar;
5653
import java.util.Date;
57-
import java.util.GregorianCalendar;
5854
import java.util.Map;
59-
import java.util.HashMap;
6055

6156
public class JSON {
6257
private Gson gson;

0 commit comments

Comments
 (0)