|
1 | 1 | /* |
2 | 2 | * -------------------------------------------------------------------------------- |
3 | 3 | * <copyright company="Aspose" file="ApiClient.java"> |
4 | | - * Copyright (c) 2020 Aspose.Words for Cloud |
| 4 | + * Copyright (c) 2021 Aspose.Words for Cloud |
5 | 5 | * </copyright> |
6 | 6 | * <summary> |
7 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
@@ -56,7 +56,7 @@ public class ApiClient { |
56 | 56 | private String apiVersion = "v4.0"; |
57 | 57 | private String baseUrl = "https://api.aspose.cloud"; |
58 | 58 | private String basePath = baseUrl + "/" + apiVersion; |
59 | | - private String clientVersion = "20.11"; |
| 59 | + private String clientVersion = "21.1"; |
60 | 60 | private boolean debugging = false; |
61 | 61 | private Map<String, String> defaultHeaderMap = new HashMap<String, String>(); |
62 | 62 | private String tempFolderPath = null; |
@@ -922,7 +922,7 @@ public Call buildCall(Request request) { |
922 | 922 | * @param body The request body object |
923 | 923 | * @param headerParams The header parameters |
924 | 924 | * @param formParams The form parameters |
925 | | - * @param authNames The authentications to apply |
| 925 | + * @param addAuthHeaders The authentications to apply |
926 | 926 | * @param progressRequestListener Progress request listener |
927 | 927 | * @return The HTTP request |
928 | 928 | * @throws ApiException If fail to serialize the request body object |
@@ -1185,6 +1185,61 @@ public Request buildBatchRequest(RequestIfc[] requests) throws ApiException, IOE |
1185 | 1185 | return buildRequest("/words/batch", "PUT", new ArrayList<>(), new ArrayList<>(), requestBody, headers, new HashMap<>(), true, null); |
1186 | 1186 | } |
1187 | 1187 |
|
| 1188 | + /** |
| 1189 | + * Parse model from online response. |
| 1190 | + */ |
| 1191 | + public Object parseModel(BodyPart bodyPart, Type returnType) throws IOException, MessagingException { |
| 1192 | + InputStream is = bodyPart.getInputStream(); |
| 1193 | + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); |
| 1194 | + |
| 1195 | + int nRead; |
| 1196 | + byte[] data = new byte[16384]; |
| 1197 | + |
| 1198 | + while ((nRead = is.read(data, 0, data.length)) != -1) { |
| 1199 | + buffer.write(data, 0, nRead); |
| 1200 | + } |
| 1201 | + |
| 1202 | + try { |
| 1203 | + String stringData = buffer.toString("UTF-8"); |
| 1204 | + return json.deserialize(stringData, returnType); |
| 1205 | + } |
| 1206 | + catch (UnsupportedEncodingException e) { |
| 1207 | + e.printStackTrace(); |
| 1208 | + } |
| 1209 | + return null; |
| 1210 | + } |
| 1211 | + |
| 1212 | + /** |
| 1213 | + * Parse document from online response. |
| 1214 | + */ |
| 1215 | + public byte[] parseDocument(BodyPart bodyPart) throws IOException, MessagingException { |
| 1216 | + InputStream is = bodyPart.getInputStream(); |
| 1217 | + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); |
| 1218 | + |
| 1219 | + int nRead; |
| 1220 | + byte[] data = new byte[16384]; |
| 1221 | + |
| 1222 | + while ((nRead = is.read(data, 0, data.length)) != -1) { |
| 1223 | + buffer.write(data, 0, nRead); |
| 1224 | + } |
| 1225 | + |
| 1226 | + return buffer.toByteArray(); |
| 1227 | + } |
| 1228 | + |
| 1229 | + /** |
| 1230 | + * Get multipart from response. |
| 1231 | + */ |
| 1232 | + public MimeMultipart getMultipartFromResponse(Response response) throws ApiException { |
| 1233 | + try { |
| 1234 | + InputStream in = response.body().byteStream(); |
| 1235 | + ByteArrayDataSource dataSource = new ByteArrayDataSource(in, "multipart/form-data"); |
| 1236 | + return new MimeMultipart(dataSource); |
| 1237 | + } |
| 1238 | + catch (IOException | MessagingException e) { |
| 1239 | + throw new ApiException(e); |
| 1240 | + } |
| 1241 | + } |
| 1242 | + |
1188 | 1243 | /** |
1189 | 1244 | * Parse batch part |
1190 | 1245 | */ |
|
0 commit comments