简体   繁体   English

AWS S3 存储桶预签名 url 问题

[英]AWS S3 Bucket Presigned url issue

I have written an API to read user posts after the token is passed in the header. API returns many posts at a time with the nested attachment name for images or videos etc. Currently, all attachments are stored in a server folder directory.在 header 中传递令牌后,我写了一个 API 来读取用户帖子。API 一次返回许多帖子,其中包含图像或视频等的嵌套附件名称。目前,所有附件都存储在服务器文件夹目录中。 Attachments is displayed by another API which accept attachment name as a parameter and return attachment url.附件由另一个 API 显示,它接受附件名称作为参数并返回附件 url。

Now I want to move on AWS S3 bucket with the same concept with presigned URL.现在我想继续使用具有相同概念的 AWS S3 存储桶,预签名为 URL。

API is being used on the flutter app. API 正在 flutter 应用程序上使用。

I created a API which accept user auth token and return upload presigned URL for s3 bucket.我创建了一个 API,它接受用户身份验证令牌并为 s3 存储桶返回上传预签名 URL。

For displaying attachments i am thinking two option.对于显示附件,我正在考虑两种选择。

  1. Create a another API which accept attachment name(object key name) and will return presigned URL of that attachment.创建另一个 API 接受附件名称(对象键名称)并将返回该附件的预签名 URL。

  2. Post API return json data after replacing all attachment name with presigned URL. But this will take too long for nested json data by looping.将所有附件名称替换为预签名的 URL 后,发布 API 返回 json 数据。但这对于循环嵌套的 json 数据来说会花费太长时间。

I am new in AWS s3 bucket.我是 AWS s3 存储桶中的新手。 Please guide what will be the best way to handle this.请指导处理此问题的最佳方法。

How facebook, twitter, instagram handle private files. facebook、twitter、instagram如何处理私人文件。

The best option I see is returning the post data with already generated pre-signed url.我看到的最佳选择是使用已生成的预签名 url 返回发布数据。

Having a separate api for generating the presigned url would mean有一个单独的 api 来生成预签名的 url 意味着

  • the system will need to authorize the input anyway (if the user is authorized to access the particular object)无论如何,系统都需要授权输入(如果用户被授权访问特定对象)
  • the user has to wait anyway until the signed links are generared, just with additional call无论如何,用户必须等待,直到生成签名链接,只需额外调用

this will take too long for nested json data by looping这将通过循环嵌套 json 数据花费太长时间

Not really, generating the presigned url makes no backend / S3 calls, it's just a bunch of HMAC computations.并非如此,生成预签名的 url 不会进行后端/S3 调用,它只是一堆 HMAC 计算。 But, as already mentioned, these need to be done regardless which option is chosen但是,正如已经提到的,无论选择哪个选项,都需要完成这些

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

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