I've come across a number of code samples/plug ins that promote uploading assets straight to S3. For instance, for those who have a person object by having an avatar, the file upload area would load straight to S3.
The only method I check this out being possible is that if the consumer object has already been produced within the database as well as your S3 bucket + path is one thing like
However should you have had a picture tag that attempted to gain access to that URL when an avatar wasn't submitted, it might yield a poor result. How does one handle checking for existence?
Also, it appears such as this wouldn't work nicely for many has numerous associations. For instance, if your user had many tunes/tunes, where can you store individuals and just how can you access them.
Also, your validations is going to be shot.
I'm getting trouble considering situations where direct upload to S3 (or any cloud) may be beneficial and was wishing people could clarify either proper use cases, or let me know why my logic is incorrect.
Why purchase storage/bandwidth/backup copies/etc. when you are able have somebody within the cloud handle it for you personally?
S3 (along with other Cloud-based storage options) handle all of the head aches for you personally. You receive all of the storage you'll need, a great distribution network (almost certainly much better than you'd have by yourself unless of course you are having to pay for any premium CDN), and backup copies.
Permitting customers to upload straight to S3 takes even a lot of bandwidth load from you. I can tell the monitoring concerns, but S3 causes it to be pretty simple to handle that situation. Should you consider the direct upload techniques, you'll notice that you are able to pressure a redirect on the effective upload.
Amazon . com will pass the next towards the redirect handler:
Which should provide you with what you ought to track the submitted resource after success. Direct uploads provide you with the better of both mobile phone industry's. You receive your monitoring information also it unloads your bandwidth.
Take a look link for particulars: Amazon . com S3: Browser-Based Uploads using Publish
If you're hosting your Rails application on Heroku, the main reason may be that Heroku does not allow file-uploads bigger than 4MB:
So if you'd like your customers to have the ability to upload large files, this is actually the only answer.