|
|
@@ -239,6 +239,30 @@ public class OssConsoleClient {
|
|
|
return webResult.getData();
|
|
|
}
|
|
|
|
|
|
+ public String getSignedUrlByUrl(int channelCode, String objectUrl) throws Exception {
|
|
|
+ String api = String.format("%s/bg/api/oss/object/sigend_url?channelCode=%s&objectUrl=%s", endpoint, channelCode, objectUrl);
|
|
|
+ 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) {
|
|
|
+ throw new Exception(body);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ return webResult.getData();
|
|
|
+ }
|
|
|
+
|
|
|
// ****************************************************************************************************************
|
|
|
// 媒体文件信息相关接口
|
|
|
// ****************************************************************************************************************
|