|
|
@@ -3,6 +3,7 @@ package cn.reghao.oss.sdk;
|
|
|
import cn.reghao.jutil.jdk.result.WebResult;
|
|
|
import cn.reghao.jutil.jdk.serializer.JsonConverter;
|
|
|
import cn.reghao.oss.api.dto.DownloadUrl;
|
|
|
+import cn.reghao.oss.api.dto.ObjectChannel;
|
|
|
import cn.reghao.oss.api.dto.ObjectInfo;
|
|
|
import cn.reghao.oss.api.dto.ServerInfo;
|
|
|
import cn.reghao.oss.api.dto.media.*;
|
|
|
@@ -21,19 +22,77 @@ import java.util.Set;
|
|
|
* @author reghao
|
|
|
* @date 2024-02-23 21:47:39
|
|
|
*/
|
|
|
-public class OssClient {
|
|
|
+public class OssConsoleClient {
|
|
|
+ private final HttpClient httpClient = HttpClient.newBuilder().build();
|
|
|
private final String endpoint;
|
|
|
- private final HttpClient httpClient;
|
|
|
+ private String token;
|
|
|
|
|
|
- public OssClient(String endpoint) {
|
|
|
+ public OssConsoleClient(String endpoint, String accessKeyId, String accessKeySecret) throws Exception {
|
|
|
this.endpoint = endpoint;
|
|
|
- this.httpClient = HttpClient.newBuilder().build();
|
|
|
+ auth(accessKeyId, accessKeySecret);
|
|
|
}
|
|
|
|
|
|
- public ServerInfo getServerInfo(long userId, int channelId) throws Exception {
|
|
|
- String api = String.format("%s/api/oss/server/info?userId=%s&channelId=%s", endpoint, userId, channelId);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ private void auth(String accessKeyId, String accessKeySecret) throws Exception {
|
|
|
+ MultiPartBodyPublisher publisher = new MultiPartBodyPublisher()
|
|
|
+ .addPart("accessKeyId", accessKeyId)
|
|
|
+ .addPart("accessKeySecret", accessKeySecret);
|
|
|
+
|
|
|
+ String api = String.format("%s/api/oss/key/auth", endpoint);
|
|
|
+ HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
+ .version(HttpClient.Version.HTTP_1_1)
|
|
|
+ .header("content-type", "multipart/form-data; boundary=" + publisher.getBoundary())
|
|
|
+ .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);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.token = webResult.getData();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void registerNode(String jsonPayload) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/store/node", endpoint);
|
|
|
+ HttpClient httpClient = HttpClient.newBuilder().build();
|
|
|
+ HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
+ .header("authorization", "Bearer " + token)
|
|
|
+ .header("content-type", "application/json")
|
|
|
+ .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
|
|
|
+ .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 ServerInfo getServerInfo(int channelId) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/server/info?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();
|
|
|
@@ -52,10 +111,63 @@ public class OssClient {
|
|
|
return webResult.getData();
|
|
|
}
|
|
|
|
|
|
+ public List<ObjectChannel> getObjectChannels(String nodeAddr) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/channels?nodeAddr=%s", endpoint, nodeAddr);
|
|
|
+ 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<List<ObjectChannel>>>(){}.getType();
|
|
|
+ WebResult<List<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 ObjectChannel getObjectChannel(String nodeAddr, int channelId) throws Exception {
|
|
|
+ String api = String.format("%s/api/oss/channel?nodeAddr=%s&channelId=%s", endpoint, nodeAddr, 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.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ 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();
|
|
|
@@ -76,8 +188,11 @@ public class OssClient {
|
|
|
|
|
|
public DownloadUrl getDownloadUrl(String objectId, int channelId, long userId) throws Exception {
|
|
|
String api = String.format("%s/api/oss/object/url?objectId=%s&channelId=%s&userId=%s", endpoint, objectId, channelId, userId);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ 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();
|
|
|
@@ -97,20 +212,22 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public void convertVideo(String videoFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/media/convert/video/%s", endpoint, videoFileId);
|
|
|
+ String api = String.format("%s/api/oss/media/convert/video/%s", endpoint, videoFileId);
|
|
|
convert(api);
|
|
|
}
|
|
|
|
|
|
public void convertAudio(String audioFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/media/convert/audio/%s", endpoint, audioFileId);
|
|
|
+ String api = String.format("%s/api/oss/media/convert/audio/%s", endpoint, audioFileId);
|
|
|
convert(api);
|
|
|
}
|
|
|
|
|
|
private void convert(String api) throws Exception {
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
-
|
|
|
MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
- HttpRequest httpRequest = builder.POST(publisher.build()).build();
|
|
|
+ HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
+ .header("authorization", "Bearer " + token)
|
|
|
+ .version(HttpClient.Version.HTTP_1_1)
|
|
|
+ .POST(publisher.build())
|
|
|
+ .build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
int statusCode = httpResponse.statusCode();
|
|
|
String body = httpResponse.body();
|
|
|
@@ -129,14 +246,16 @@ public class OssClient {
|
|
|
|
|
|
@Deprecated
|
|
|
public void setVideoScope(String videoFileId, int scope) throws Exception {
|
|
|
- String api = String.format("%s/api/media/scope/video", endpoint);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
-
|
|
|
MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
publisher.addPart("videoId", videoFileId);
|
|
|
publisher.addPart("scope", scope+"");
|
|
|
|
|
|
- HttpRequest httpRequest = builder.POST(publisher.build()).build();
|
|
|
+ String api = String.format("%s/api/oss/media/scope/video", endpoint);
|
|
|
+ HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
+ .header("authorization", "Bearer " + token)
|
|
|
+ .version(HttpClient.Version.HTTP_1_1)
|
|
|
+ .POST(publisher.build())
|
|
|
+ .build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
int statusCode = httpResponse.statusCode();
|
|
|
String body = httpResponse.body();
|
|
|
@@ -155,14 +274,16 @@ public class OssClient {
|
|
|
|
|
|
@Deprecated
|
|
|
public void setAudioScope(String audioFileId, int scope) throws Exception {
|
|
|
- String api = String.format("%s/api/media/scope/audio", endpoint);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
-
|
|
|
MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
publisher.addPart("audioFileId", audioFileId);
|
|
|
publisher.addPart("scope", scope+"");
|
|
|
|
|
|
- HttpRequest httpRequest = builder.POST(publisher.build()).build();
|
|
|
+ String api = String.format("%s/api/oss/media/scope/audio", endpoint);
|
|
|
+ HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
+ .header("authorization", "Bearer " + token)
|
|
|
+ .version(HttpClient.Version.HTTP_1_1)
|
|
|
+ .POST(publisher.build())
|
|
|
+ .build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
int statusCode = httpResponse.statusCode();
|
|
|
String body = httpResponse.body();
|
|
|
@@ -181,14 +302,16 @@ public class OssClient {
|
|
|
|
|
|
@Deprecated
|
|
|
public void setImagesScope(Set<String> imageFileIds, int scope) throws Exception {
|
|
|
- String api = String.format("%s/api/media/scope/image", endpoint);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
-
|
|
|
+ String api = String.format("%s/api/oss/media/scope/image", endpoint);
|
|
|
MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
publisher.addPart("imageFileIds", imageFileIds.toString());
|
|
|
publisher.addPart("scope", scope+"");
|
|
|
|
|
|
- HttpRequest httpRequest = builder.POST(publisher.build()).build();
|
|
|
+ HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
+ .header("authorization", "Bearer " + token)
|
|
|
+ .version(HttpClient.Version.HTTP_1_1)
|
|
|
+ .POST(publisher.build())
|
|
|
+ .build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
int statusCode = httpResponse.statusCode();
|
|
|
String body = httpResponse.body();
|
|
|
@@ -206,15 +329,17 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public void setObjectScope(int scope, String objectId, int contentType) throws Exception {
|
|
|
- String api = String.format("%s/api/media/scope/object", endpoint);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
-
|
|
|
+ String api = String.format("%s/api/oss/media/scope/object", endpoint);
|
|
|
MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
publisher.addPart("scope", scope+"");
|
|
|
publisher.addPart("objectId", objectId);
|
|
|
publisher.addPart("contentType", contentType+"");
|
|
|
|
|
|
- HttpRequest httpRequest = builder.POST(publisher.build()).build();
|
|
|
+ HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
+ .header("authorization", "Bearer " + token)
|
|
|
+ .version(HttpClient.Version.HTTP_1_1)
|
|
|
+ .POST(publisher.build())
|
|
|
+ .build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
int statusCode = httpResponse.statusCode();
|
|
|
String body = httpResponse.body();
|
|
|
@@ -232,15 +357,17 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public void setObjectsScope(int scope, List<String> objectIds, int contentType) throws Exception {
|
|
|
- String api = String.format("%s/api/media/scope/objects", endpoint);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
-
|
|
|
+ String api = String.format("%s/api/oss/media/scope/objects", endpoint);
|
|
|
MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
publisher.addPart("scope", scope+"");
|
|
|
publisher.addPart("objectIds", objectIds.toString());
|
|
|
publisher.addPart("contentType", contentType+"");
|
|
|
|
|
|
- HttpRequest httpRequest = builder.POST(publisher.build()).build();
|
|
|
+ HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
+ .header("authorization", "Bearer " + token)
|
|
|
+ .version(HttpClient.Version.HTTP_1_1)
|
|
|
+ .POST(publisher.build())
|
|
|
+ .build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
int statusCode = httpResponse.statusCode();
|
|
|
String body = httpResponse.body();
|
|
|
@@ -258,9 +385,12 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public AudioInfo getAudioInfo(String audioFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/media/audio/info/%s", endpoint, audioFileId);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ String api = String.format("%s/api/oss/media/audio/info/%s", endpoint, audioFileId);
|
|
|
+ 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();
|
|
|
@@ -280,9 +410,12 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public List<AudioUrl> getAudioUrls(String audioFileId, long loginUser) throws Exception {
|
|
|
- String api = String.format("%s/api/media/audio/url?audioFileId=%s&userId=%s", endpoint, audioFileId, loginUser);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ String api = String.format("%s/api/oss/media/audio/url?audioFileId=%s&userId=%s", endpoint, audioFileId, loginUser);
|
|
|
+ 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();
|
|
|
@@ -302,7 +435,7 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public void deleteByObjectNames(List<String> objectNames) throws Exception {
|
|
|
- String api = String.format("%s/api/media/image/delete/name", endpoint);
|
|
|
+ String api = String.format("%s/api/oss/media/image/delete/name", endpoint);
|
|
|
HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
|
|
|
MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
@@ -326,7 +459,7 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public void deleteByImageFileIds(List<String> imageFileIds) throws Exception {
|
|
|
- String api = String.format("%s/api/media/image/delete/id", endpoint);
|
|
|
+ String api = String.format("%s/api/oss/media/image/delete/id", endpoint);
|
|
|
HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
|
|
|
MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
|
|
|
@@ -350,10 +483,13 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public ImageUrlDto getImageUrl(int channelId, String imageFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/media/image/url?channelId=%s&imageFileId=%s", endpoint, channelId, imageFileId);
|
|
|
- //String api = String.format("%s/api/media/image/url?channelId=%s&imageFileId=%s&loginUser=%s", endpoint, channelId, imageFileId);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ String api = String.format("%s/api/oss/media/image/url?channelId=%s&imageFileId=%s", endpoint, channelId, imageFileId);
|
|
|
+ //String api = String.format("%s/api/oss/media/image/url?channelId=%s&imageFileId=%s&loginUser=%s", endpoint, channelId, imageFileId);
|
|
|
+ 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();
|
|
|
@@ -373,9 +509,12 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public ImageUrlDto getImageUrl(String imageFileId, long loginUser, int channelId) throws Exception {
|
|
|
- String api = String.format("%s/api/media/image/url?channelId=%s&imageFileId=%s&loginUser=%s", endpoint, channelId, imageFileId, loginUser);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ String api = String.format("%s/api/oss/media/image/url?channelId=%s&imageFileId=%s&loginUser=%s", endpoint, channelId, imageFileId, loginUser);
|
|
|
+ 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();
|
|
|
@@ -395,9 +534,12 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public List<ImageUrlDto> getImageUrls(Set<String> imageFileIds) throws Exception {
|
|
|
- String api = String.format("%s/api/media/image/urls?imageFileIds=%s", endpoint, imageFileIds.toString());
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ String api = String.format("%s/api/oss/media/image/urls?imageFileIds=%s", endpoint, imageFileIds.toString());
|
|
|
+ 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();
|
|
|
@@ -417,9 +559,12 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public String getSignedUrl(String url, long loginUser, int channelId) throws Exception {
|
|
|
- String api = String.format("%s/api/media/image/signedurl?channelId=%s&url=%s&loginUser=%s", endpoint, channelId, url, loginUser);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ String api = String.format("%s/api/oss/media/image/signedurl?channelId=%s&url=%s&loginUser=%s", endpoint, channelId, url, loginUser);
|
|
|
+ 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();
|
|
|
@@ -439,7 +584,7 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public void deleteVideoFile(String videoFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/media/video/delete/%s", endpoint, videoFileId);
|
|
|
+ String api = String.format("%s/api/oss/media/video/delete/%s", endpoint, videoFileId);
|
|
|
HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
HttpRequest httpRequest = builder.DELETE().build();
|
|
|
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
@@ -459,9 +604,12 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public VideoInfo getVideoInfo(String videoFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/media/video/info/%s", endpoint, videoFileId);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ String api = String.format("%s/api/oss/media/video/info/%s", endpoint, videoFileId);
|
|
|
+ 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();
|
|
|
@@ -481,9 +629,12 @@ public class OssClient {
|
|
|
}
|
|
|
|
|
|
public List<VideoUrlDto> getVideoUrls(String videoFileId, long loginUser) throws Exception {
|
|
|
- String api = String.format("%s/api/media/video/url?videoFileId=%s&userId=%s", endpoint, videoFileId, loginUser);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ String api = String.format("%s/api/oss/media/video/url?videoFileId=%s&userId=%s", endpoint, videoFileId, loginUser);
|
|
|
+ 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();
|
|
|
@@ -502,10 +653,14 @@ public class OssClient {
|
|
|
return webResult.getData();
|
|
|
}
|
|
|
|
|
|
+ @Deprecated
|
|
|
public LocalDateTime getCreateTime(String videoFileId) throws Exception {
|
|
|
- String api = String.format("%s/api/media/video/time/%s", endpoint, videoFileId);
|
|
|
- HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
|
|
|
- HttpRequest httpRequest = builder.GET().build();
|
|
|
+ String api = String.format("%s/api/oss/media/video/time/%s", endpoint, videoFileId);
|
|
|
+ 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();
|