|
|
@@ -193,6 +193,31 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
|
}
|
|
|
|
|
|
+ public ObjectChannel getObjectChannel(int channelId) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/server/channel?channelId=%s", endpoint, channelId);
|
|
|
+ HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
+ .header("authorization", "Bearer " + token)
|
|
|
+ .version(HttpClient.Version.HTTP_1_1)
|
|
|
+ .GET()
|
|
|
+ .build();
|
|
|
+ HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
+ int statusCode = httpResponse.statusCode();
|
|
|
+ String body = httpResponse.body();
|
|
|
+ if (statusCode != 200) {
|
|
|
+ String errMsg = String.format("%s -> %s", statusCode, body);
|
|
|
+ throw new Exception(errMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ Type type = new TypeToken<WebResult<ObjectChannel>>(){}.getType();
|
|
|
+ WebResult<ObjectChannel> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
+ if (webResult.getCode() != 0) {
|
|
|
+ String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
|
|
|
+ throw new Exception(errMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return webResult.getData();
|
|
|
+ }
|
|
|
+
|
|
|
public ObjectInfo getObjectInfo(String objectId) throws Exception {
|
|
|
String api = String.format("%s/api/oss/object/info?objectId=%s", endpoint, objectId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
@@ -277,18 +302,19 @@ public class OssConsoleClient {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void setObjectsScope(int scope, List<String> objectIds, int contentType) throws Exception {
|
|
|
- String objectIdsStr = objectIds.toString().replace("[", "").replace("]", "");
|
|
|
- String api = String.format("%s/api/oss/media/scope/objects", endpoint);
|
|
|
- MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
- publisher.addPart("scope", scope+"");
|
|
|
- publisher.addPart("objectIds", objectIdsStr);
|
|
|
- publisher.addPart("contentType", contentType+"");
|
|
|
+ public void setObjectsScope(int channelId, List<String> objectNames, int scope) throws Exception {
|
|
|
+ String objectNamesStr = objectNames.toString().replace("[", "").replace("]", "");
|
|
|
+ Map<String, String> formData = new HashMap<>();
|
|
|
+ formData.put("channelId", channelId+"");
|
|
|
+ formData.put("scope", scope+"");
|
|
|
+ formData.put("objectNames", objectNamesStr);
|
|
|
|
|
|
+ String api = String.format("%s/api/oss/media/scope/objects", endpoint);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
|
+ .headers("content-type", "application/x-www-form-urlencoded")
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
|
- .POST(publisher.build())
|
|
|
+ .POST(HttpRequest.BodyPublishers.ofString(getFormDataAsString(formData)))
|
|
|
.build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
int statusCode = httpResponse.statusCode();
|
|
|
@@ -453,11 +479,16 @@ public class OssConsoleClient {
|
|
|
|
|
|
public List<ImageUrlDto> getImageUrls(int channelId, Set<String> imageFileIds) throws Exception {
|
|
|
String imageFileIdsStr = imageFileIds.toString().replace("[", "").replace("]", "");
|
|
|
- String api = String.format("%s/api/oss/media/image/urls?channelId=%s&imageFileIds=%s", endpoint, channelId, imageFileIdsStr);
|
|
|
+ Map<String, String> formData = new HashMap<>();
|
|
|
+ formData.put("channelId", channelId+"");
|
|
|
+ formData.put("imageFileIds", imageFileIdsStr);
|
|
|
+
|
|
|
+ String api = String.format("%s/api/oss/media/image/urls", endpoint);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
|
+ .headers("content-type", "application/x-www-form-urlencoded")
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
|
- .GET()
|
|
|
+ .POST(HttpRequest.BodyPublishers.ofString(getFormDataAsString(formData)))
|
|
|
.build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
int statusCode = httpResponse.statusCode();
|