简体   繁体   English

如何在java中集成签名的URL?

[英]How to integrate signed URL in java?

I am trying to use DOLBY.IO's media API to transcode and save the output file to cloud.我正在尝试使用DOLBY.IO's media API进行转码并将输出文件保存到云端。 I have two URLs {URL1:input to dolby;我有两个 URL {URL1:input to dolby; URL2: to store output from dolby}. URL2:存储 dolby 的输出}。 And both the URLs are signed URLs from the same cloud.并且这两个 URL 都是来自同一个云的签名 URL。

I tried using some java code to accomplish this but in the end I still can't get the result.我尝试使用一些java代码来完成这个,但最后我仍然无法得到结果。

Here is the code:这是代码:

@PostMapping("/transcode")
    public String Video_Transcode1() throws IOException, JSONException {
        OkHttpClient client = new OkHttpClient();
        String data=generate_Access_token( );
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\"inputs\":[{\"source\":\"https://vb-object-storage.ap-south-1.linodeobjects.com/The%20Hindu%20Daily%20News%20Analysis%20__%203rd%20July%202022%20__%20UPSC%20Current%20Affairs%20__%20Prelims%20%2722%20%26%20Mains%20%2722%28360%29.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20220707T073322Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604799&X-Amz-Credential=ZVADROBVHWLK1FOYT225%2F20220707%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=0aa4b388ea3197dd8a03253f5f7313b4209b8acf5e0a4308dc5e543801d22c73\"}],\"outputs\":[{\"kind\":\"mp4\",\"destination\":\"https://vb-object-storage.ap-south-1.linodeobjects.com/The%20Hindu%20Daily%20News%20Analysis%20__%203rd%20July%202022%20__%20UPSC%20Current%20Affairs%20__%20Prelims%20%2722%20%26%20Mains%20%2722%28360%29.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20220707T073322Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604799&X-Amz-Credential=ZVADROBVHWLK1FOYT225%2F20220707%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=0aa4b388ea3197dd8a03253f5f7313b4209b8acf5e0a4308dc5e543801d22c73\"}]}");
        Request request = new Request.Builder()
          .url("https://api.dolby.com/media/transcode")
          .post(body)
          .addHeader("Accept", "application/json")
          .addHeader("Content-Type", "application/json")
          .addHeader("Authorization","Bearer "+data)
          .build();

        Response response = client.newCall(request).execute();
        return response.toString();
    }

Here the data is generated from another function (ie:Access token)这里的数据是从另一个函数生成的(即:访问令牌)

I have encoded two URLs as json here:我在这里将两个 URL 编码为 json:

 RequestBody body = RequestBody.create(mediaType, "{\"inputs\":[{\"source\":\"https://vb-object-storage.ap-south-1.linodeobjects.com/The%20Hindu%20Daily%20News%20Analysis%20__%203rd%20July%202022%20__%20UPSC%20Current%20Affairs%20__%20Prelims%20%2722%20%26%20Mains%20%2722%28360%29.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20220707T073322Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604799&X-Amz-Credential=ZVADROBVHWLK1FOYT225%2F20220707%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=0aa4b388ea3197dd8a03253f5f7313b4209b8acf5e0a4308dc5e543801d22c73\"}],\"outputs\":[{\"kind\":\"mp4\",\"destination\":\"https://vb-object-storage.ap-south-1.linodeobjects.com/The%20Hindu%20Daily%20News%20Analysis%20__%203rd%20July%202022%20__%20UPSC%20Current%20Affairs%20__%20Prelims%20%2722%20%26%20Mains%20%2722%28360%29.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20220707T073322Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604799&X-Amz-Credential=ZVADROBVHWLK1FOYT225%2F20220707%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=0aa4b388ea3197dd8a03253f5f7313b4209b8acf5e0a4308dc5e543801d22c73\"}]}");

Is there any look around to bring the solution.是否有任何环顾四周来带来解决方案。

it looks like both signed URLs might be GET urls?看起来两个签名的 URL 都可能是 GET url?

For the Dolby.io Transcode API, your inputs should be GET signed urls and your outputs should be PUT signed URLs.对于 Dolby.io Transcode API,您的inputs应该是 GET 签名的 URL,您的outputs应该是 PUT 签名的 URL。

Additionally, it also looks like you are using the same input path/filename and output path/filename:此外,看起来您使用的是相同的输入路径/文件名和输出路径/文件名:

https://vb-object-storage.ap-south-1.linodeobjects.com/The%20Hindu%20Daily%20News%20Analysis%20__%203rd%20July%202022%20__%20UPSC%20Current%20Affairs%20__%20Prelims%20%2722%20%26%20Mains%20%2722%28360%29.mp4

You will want to use different paths for input and output, something like:您将希望对输入和输出使用不同的路径,例如:

https://vb-object-storage.ap-south-1.linodeobjects.com/output/outputfile.mp4

(note the "output" added to the path and the change of the output filename) (注意添加到路径的“输出”和输出文件名的变化)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM