|
|
@@ -199,40 +199,6 @@ public class OssConsoleClient {
|
|
|
// ****************************************************************************************************************
|
|
|
// Object 相关接口
|
|
|
// ****************************************************************************************************************
|
|
|
- public void setObjectScope(int channelId, String objectId, int scope) throws Exception {
|
|
|
- /*MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
- publisher.addPart("scope", scope+"");
|
|
|
- publisher.addPart("objectId", objectId);
|
|
|
- publisher.addPart("contentType", contentType+"");*/
|
|
|
-
|
|
|
- Map<String, String> formData = new HashMap<>();
|
|
|
- formData.put("channelId", channelId+"");
|
|
|
- formData.put("objectId", objectId);
|
|
|
- formData.put("scope", scope+"");
|
|
|
-
|
|
|
- String api = String.format("%s/api/oss/object/scope/object", 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(HttpRequest.BodyPublishers.ofString(getFormDataAsString(formData)))
|
|
|
- .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<String>>(){}.getType();
|
|
|
- WebResult<String> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
- if (webResult.getCode() != 0) {
|
|
|
- String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
|
|
|
- throw new Exception(errMsg);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public void setObjectsScope(int channelId, List<String> objectIds, int scope) throws Exception {
|
|
|
String objectIdsStr = objectIds.toString().replace("[", "").replace("]", "");
|
|
|
Map<String, String> formData = new HashMap<>();
|
|
|
@@ -276,93 +242,13 @@ public class OssConsoleClient {
|
|
|
return formBodyBuilder.toString();
|
|
|
}
|
|
|
|
|
|
- public void deleteByObjectNames(List<String> objectNames) throws Exception {
|
|
|
- String api = String.format("%s/api/oss/object/delete/name", endpoint);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
-
|
|
|
- String objectNamesStr = objectNames.toString().replace("[", "").replace("]", "");
|
|
|
- MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
- publisher.addPart("objectNames", objectNamesStr);
|
|
|
-
|
|
|
- HttpRequest httpRequest = builder.POST(publisher.build()).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<String>>(){}.getType();
|
|
|
- WebResult<String> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
- if (webResult.getCode() != 0) {
|
|
|
- String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
|
|
|
- throw new Exception(errMsg);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public DownloadUrl getDownloadUrl(String objectId) throws Exception {
|
|
|
- String api = String.format("%s/api/oss/object/url?objectId=%s", endpoint, objectId);
|
|
|
- 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<DownloadUrl>>(){}.getType();
|
|
|
- WebResult<DownloadUrl> 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(int channelId, String objectId) throws Exception {
|
|
|
- String api = String.format("%s/api/oss/object/info?channelId=%s&objectId=%s", endpoint, channelId, objectId);
|
|
|
- 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<ObjectInfo>>(){}.getType();
|
|
|
- WebResult<ObjectInfo> 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 void setMediaScope(int channelId, int contentType, List<String> mediaIds, int scope) throws Exception {
|
|
|
- String mediaIdsStr = mediaIds.toString().replace("[", "").replace("]", "");
|
|
|
+ public void deleteByObjectIds(int channelId, List<String> objectIds) throws Exception {
|
|
|
+ String objectIdsStr = objectIds.toString().replace("[", "").replace("]", "");
|
|
|
Map<String, String> formData = new HashMap<>();
|
|
|
formData.put("channelId", channelId+"");
|
|
|
- formData.put("contentType", contentType+"");
|
|
|
- formData.put("mediaIds", mediaIdsStr);
|
|
|
- formData.put("scope", scope+"");
|
|
|
+ formData.put("objectIds", objectIdsStr);
|
|
|
|
|
|
- String api = String.format("%s/api/oss/media/scope", endpoint);
|
|
|
+ String api = String.format("%s/api/oss/object/delete/ids", endpoint);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
|
.headers("content-type", "application/x-www-form-urlencoded")
|
|
|
@@ -385,14 +271,11 @@ public class OssConsoleClient {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void deleteMediaFile(int channelId, int contentType, List<String> mediaIds) throws Exception {
|
|
|
- String mediaIdsStr = mediaIds.toString().replace("[", "").replace("]", "");
|
|
|
+ public void deleteByObjectUrl(String objectUrl) throws Exception {
|
|
|
Map<String, String> formData = new HashMap<>();
|
|
|
- formData.put("channelId", channelId+"");
|
|
|
- formData.put("contentType", contentType+"");
|
|
|
- formData.put("mediaIds", mediaIdsStr);
|
|
|
+ formData.put("objectUrl", objectUrl);
|
|
|
|
|
|
- String api = String.format("%s/api/oss/media/delete", endpoint);
|
|
|
+ String api = String.format("%s/api/oss/object/delete/url", endpoint);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
|
.headers("content-type", "application/x-www-form-urlencoded")
|
|
|
@@ -415,8 +298,8 @@ public class OssConsoleClient {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public List<VideoUrlDto> getVideoUrls(int channelId, String videoFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/oss/media/video/url?channelId=%s&videoFileId=%s", endpoint, channelId, videoFileId);
|
|
|
+ public String getSignedUrl(int channelId, String objectId) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/object/url?channelId=%s&objectId=%s", endpoint, channelId, objectId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
|
@@ -430,8 +313,8 @@ public class OssConsoleClient {
|
|
|
throw new Exception(errMsg);
|
|
|
}
|
|
|
|
|
|
- Type type = new TypeToken<WebResult<List<VideoUrlDto>>>(){}.getType();
|
|
|
- WebResult<List<VideoUrlDto>> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
+ Type type = new TypeToken<WebResult<String>>(){}.getType();
|
|
|
+ WebResult<String> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
if (webResult.getCode() != 0) {
|
|
|
String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
|
|
|
throw new Exception(errMsg);
|
|
|
@@ -440,8 +323,8 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
|
}
|
|
|
|
|
|
- public VideoInfo getVideoInfo(int channelId, String videoFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/oss/media/video/info?channelId=%s&videoFileId=%s", endpoint, channelId, videoFileId);
|
|
|
+ public ObjectInfo getObjectInfo(int channelId, String objectId) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/object/info?channelId=%s&objectId=%s", endpoint, channelId, objectId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
|
@@ -455,8 +338,8 @@ public class OssConsoleClient {
|
|
|
throw new Exception(errMsg);
|
|
|
}
|
|
|
|
|
|
- Type type = new TypeToken<WebResult<VideoInfo>>(){}.getType();
|
|
|
- WebResult<VideoInfo> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
+ Type type = new TypeToken<WebResult<ObjectInfo>>(){}.getType();
|
|
|
+ WebResult<ObjectInfo> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
if (webResult.getCode() != 0) {
|
|
|
String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
|
|
|
throw new Exception(errMsg);
|
|
|
@@ -465,18 +348,15 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
|
}
|
|
|
|
|
|
- public List<ImageUrlDto> getImageUrls(int channelId, Set<String> imageFileIds) throws Exception {
|
|
|
- String imageFileIdsStr = imageFileIds.toString().replace("[", "").replace("]", "");
|
|
|
- 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);
|
|
|
+ // ****************************************************************************************************************
|
|
|
+ // 媒体文件相关接口
|
|
|
+ // ****************************************************************************************************************
|
|
|
+ public VideoInfo getVideoInfo(int channelId, String videoFileId) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/media/video/info?channelId=%s&videoFileId=%s", endpoint, channelId, videoFileId);
|
|
|
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(HttpRequest.BodyPublishers.ofString(getFormDataAsString(formData)))
|
|
|
+ .GET()
|
|
|
.build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
int statusCode = httpResponse.statusCode();
|
|
|
@@ -486,8 +366,8 @@ public class OssConsoleClient {
|
|
|
throw new Exception(errMsg);
|
|
|
}
|
|
|
|
|
|
- Type type = new TypeToken<WebResult<List<ImageUrlDto>>>(){}.getType();
|
|
|
- WebResult<List<ImageUrlDto>> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
+ Type type = new TypeToken<WebResult<VideoInfo>>(){}.getType();
|
|
|
+ WebResult<VideoInfo> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
if (webResult.getCode() != 0) {
|
|
|
String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
|
|
|
throw new Exception(errMsg);
|
|
|
@@ -496,8 +376,8 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
|
}
|
|
|
|
|
|
- public List<AudioUrl> getAudioUrls(String audioFileId, int loginUser) throws Exception {
|
|
|
- String api = String.format("%s/api/oss/media/audio/url?audioFileId=%s&userId=%s", endpoint, audioFileId, loginUser);
|
|
|
+ public ImageInfo getImageInfo(int channelId, String imageFileId) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/media/image/info?channelId=%s&videoFileId=%s", endpoint, channelId, imageFileId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
|
@@ -511,8 +391,8 @@ public class OssConsoleClient {
|
|
|
throw new Exception(errMsg);
|
|
|
}
|
|
|
|
|
|
- Type type = new TypeToken<WebResult<List<AudioUrl>>>(){}.getType();
|
|
|
- WebResult<List<AudioUrl>> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
+ Type type = new TypeToken<WebResult<ImageInfo>>(){}.getType();
|
|
|
+ WebResult<ImageInfo> webResult = JsonConverter.jsonToObject(body, type);
|
|
|
if (webResult.getCode() != 0) {
|
|
|
String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
|
|
|
throw new Exception(errMsg);
|
|
|
@@ -521,8 +401,8 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
|
}
|
|
|
|
|
|
- public AudioInfo getAudioInfo(String audioFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/oss/media/audio/info/%s", endpoint, audioFileId);
|
|
|
+ public AudioInfo getAudioInfo(int channelId, String audioFileId) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/media/audio/info/?channelId=%s&audioFileId=%s", endpoint, channelId, audioFileId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|