|
@@ -70,8 +70,8 @@ public class OssConsoleClient {
|
|
|
// ****************************************************************************************************************
|
|
// ****************************************************************************************************************
|
|
|
// oss-store 相关接口
|
|
// oss-store 相关接口
|
|
|
// ****************************************************************************************************************
|
|
// ****************************************************************************************************************
|
|
|
- public ServerInfo getUploadStore(int channelId) throws Exception {
|
|
|
|
|
- String api = String.format("%s/api/oss/upload/store?channelId=%s", endpoint, channelId);
|
|
|
|
|
|
|
+ public ServerInfo getUploadStore(int channelCode) throws Exception {
|
|
|
|
|
+ String api = String.format("%s/api/oss/upload/store?channelCode=%s", endpoint, channelCode);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
.header("authorization", "Bearer " + token)
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
@@ -95,9 +95,9 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
return webResult.getData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void setObjectScope(int channelId, String objectId, int scope) throws Exception {
|
|
|
|
|
|
|
+ public void setObjectScope(int channelCode, String objectId, int scope) throws Exception {
|
|
|
Map<String, String> formData = new HashMap<>();
|
|
Map<String, String> formData = new HashMap<>();
|
|
|
- formData.put("channelId", channelId+"");
|
|
|
|
|
|
|
+ formData.put("channelCode", channelCode+"");
|
|
|
formData.put("scope", scope+"");
|
|
formData.put("scope", scope+"");
|
|
|
formData.put("objectId", objectId);
|
|
formData.put("objectId", objectId);
|
|
|
|
|
|
|
@@ -137,9 +137,9 @@ public class OssConsoleClient {
|
|
|
return formBodyBuilder.toString();
|
|
return formBodyBuilder.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void deleteByObjectId(int channelId, String objectId) throws Exception {
|
|
|
|
|
|
|
+ public void deleteByObjectId(int channelCode, String objectId) throws Exception {
|
|
|
Map<String, String> formData = new HashMap<>();
|
|
Map<String, String> formData = new HashMap<>();
|
|
|
- formData.put("channelId", channelId+"");
|
|
|
|
|
|
|
+ formData.put("channelCode", channelCode+"");
|
|
|
formData.put("objectId", objectId);
|
|
formData.put("objectId", objectId);
|
|
|
|
|
|
|
|
String api = String.format("%s/api/oss/object/delete/id", endpoint);
|
|
String api = String.format("%s/api/oss/object/delete/id", endpoint);
|
|
@@ -192,8 +192,8 @@ public class OssConsoleClient {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- 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);
|
|
|
|
|
|
|
+ public ObjectInfo getObjectInfo(int channelCode, String objectId) throws Exception {
|
|
|
|
|
+ String api = String.format("%s/api/oss/object/info?channelCode=%s&objectId=%s", endpoint, channelCode, objectId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
.header("authorization", "Bearer " + token)
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
@@ -217,8 +217,8 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
return webResult.getData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- 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);
|
|
|
|
|
|
|
+ public String getSignedUrl(int channelCode, String objectId) throws Exception {
|
|
|
|
|
+ String api = String.format("%s/api/oss/object/url?channelCode=%s&objectId=%s", endpoint, channelCode, objectId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
.header("authorization", "Bearer " + token)
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
@@ -242,8 +242,8 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
return webResult.getData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public VideoInfo getVideoInfo(int channelId, String objectId) throws Exception {
|
|
|
|
|
- String api = String.format("%s/api/oss/object/video/info?channelId=%s&objectId=%s", endpoint, channelId, objectId);
|
|
|
|
|
|
|
+ public VideoInfo getVideoInfo(int channelCode, String objectId) throws Exception {
|
|
|
|
|
+ String api = String.format("%s/api/oss/object/video/info?channelCode=%s&objectId=%s", endpoint, channelCode, objectId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
.header("authorization", "Bearer " + token)
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
@@ -267,8 +267,8 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
return webResult.getData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public ImageInfo getImageInfo(int channelId, String objectId) throws Exception {
|
|
|
|
|
- String api = String.format("%s/api/oss/object/image/info?channelId=%s&objectId=%s", endpoint, channelId, objectId);
|
|
|
|
|
|
|
+ public ImageInfo getImageInfo(int channelCode, String objectId) throws Exception {
|
|
|
|
|
+ String api = String.format("%s/api/oss/object/image/info?channelCode=%s&objectId=%s", endpoint, channelCode, objectId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
.header("authorization", "Bearer " + token)
|
|
|
.headers("content-type", "application/x-www-form-urlencoded")
|
|
.headers("content-type", "application/x-www-form-urlencoded")
|
|
@@ -293,9 +293,9 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
return webResult.getData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public ConvertedImageInfo getWebpInfo(int channelId, String objectId) throws Exception {
|
|
|
|
|
|
|
+ public ConvertedImageInfo getWebpInfo(int channelCode, String objectId) throws Exception {
|
|
|
Map<String, String> formData = new HashMap<>();
|
|
Map<String, String> formData = new HashMap<>();
|
|
|
- formData.put("channelId", ""+channelId);
|
|
|
|
|
|
|
+ formData.put("channelCode", ""+channelCode);
|
|
|
formData.put("objectId", objectId);
|
|
formData.put("objectId", objectId);
|
|
|
|
|
|
|
|
String api = String.format("%s/api/oss/object/image/webp", endpoint);
|
|
String api = String.format("%s/api/oss/object/image/webp", endpoint);
|
|
@@ -323,8 +323,8 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
return webResult.getData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public AudioInfo getAudioInfo(int channelId, String objectId) throws Exception {
|
|
|
|
|
- String api = String.format("%s/api/oss/object/audio/info/?channelId=%s&objectId=%s", endpoint, channelId, objectId);
|
|
|
|
|
|
|
+ public AudioInfo getAudioInfo(int channelCode, String objectId) throws Exception {
|
|
|
|
|
+ String api = String.format("%s/api/oss/object/audio/info/?channelCode=%s&objectId=%s", endpoint, channelCode, objectId);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.header("authorization", "Bearer " + token)
|
|
.header("authorization", "Bearer " + token)
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
@@ -387,8 +387,8 @@ public class OssConsoleClient {
|
|
|
// ****************************************************************************************************************
|
|
// ****************************************************************************************************************
|
|
|
// 对象访问接口
|
|
// 对象访问接口
|
|
|
// ****************************************************************************************************************
|
|
// ****************************************************************************************************************
|
|
|
- public UploadFileRet postObject(File file, int channelId) throws Exception {
|
|
|
|
|
- ServerInfo serverInfo = getUploadStore(channelId);
|
|
|
|
|
|
|
+ public UploadFileRet postObject(File file, int channelCode) throws Exception {
|
|
|
|
|
+ ServerInfo serverInfo = getUploadStore(channelCode);
|
|
|
if (serverInfo == null) {
|
|
if (serverInfo == null) {
|
|
|
throw new Exception("获取 server_info 失败");
|
|
throw new Exception("获取 server_info 失败");
|
|
|
}
|
|
}
|
|
@@ -396,12 +396,12 @@ public class OssConsoleClient {
|
|
|
String token = serverInfo.getToken();
|
|
String token = serverInfo.getToken();
|
|
|
|
|
|
|
|
OssStoreClient ossStoreClient = new OssStoreClient(ossUrl);
|
|
OssStoreClient ossStoreClient = new OssStoreClient(ossUrl);
|
|
|
- UploadFileRet uploadFileRet = ossStoreClient.postObjectWithJdkHttp(file, channelId, token);
|
|
|
|
|
|
|
+ UploadFileRet uploadFileRet = ossStoreClient.postObjectWithJdkHttp(file, channelCode, token);
|
|
|
return uploadFileRet;
|
|
return uploadFileRet;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public UploadFileRet postObjectByMultiparts(File file, int channelId) throws Exception {
|
|
|
|
|
- ServerInfo serverInfo = getUploadStore(channelId);
|
|
|
|
|
|
|
+ public UploadFileRet postObjectByMultiparts(File file, int channelCode) throws Exception {
|
|
|
|
|
+ ServerInfo serverInfo = getUploadStore(channelCode);
|
|
|
if (serverInfo == null) {
|
|
if (serverInfo == null) {
|
|
|
throw new Exception("获取 server_info 失败");
|
|
throw new Exception("获取 server_info 失败");
|
|
|
}
|
|
}
|
|
@@ -409,7 +409,7 @@ public class OssConsoleClient {
|
|
|
String token = serverInfo.getToken();
|
|
String token = serverInfo.getToken();
|
|
|
|
|
|
|
|
ObjectMultipartUploadService multipartUploadService = new ObjectMultipartUploadService(ossUrl, token);
|
|
ObjectMultipartUploadService multipartUploadService = new ObjectMultipartUploadService(ossUrl, token);
|
|
|
- UploadFileRet uploadFileRet = multipartUploadService.uploadFilePart(file, channelId);
|
|
|
|
|
|
|
+ UploadFileRet uploadFileRet = multipartUploadService.uploadFilePart(file, channelCode);
|
|
|
return uploadFileRet;
|
|
return uploadFileRet;
|
|
|
}
|
|
}
|
|
|
|
|
|