开发者

how to handle s3 browser-based uploads?

开发者 https://www.devze.com 2023-02-27 19:00 出处:网络
There is a website, and we want to allow users to upload files for their entities. We managed to make a form which uploads files to s3开发者_StackOverflow中文版 directly from browser.

There is a website, and we want to allow users to upload files for their entities.

We managed to make a form which uploads files to s3开发者_StackOverflow中文版 directly from browser.

However, it is not very reliable for at least two reasons:

  • apart from post-upload redirects, there does not seem to be a way to notify our application about uploaded files
  • user can upload anything he wants, with whatever names he wants, and we should have something like a "janitor" to remove junk

What's your strategy with dealing with such files? Or we should just give up and upload to s3 from our web application?


Post upload redirects is the way that your application gets notified. Why is this not working for you? If using the post directly to Amazon from your form method, there is no alternative notification.

You can put in place restrictions or controls on the files that are uploaded using the hidden field values that are required in the form (ie. key, Content-Type, etc.) You can even rename the name a file is saved as using the "key" hidden field.

Using the above concepts and also implementing some client side validation should achieve what you need in most cases.

Depending on the technology are resources you have available, uploading through the web application can tie up resources, particularly if large file uploads are allowed. This is the big advantage to direct to S3 uploads.

0

精彩评论

暂无评论...
验证码 换一张
取 消