Exactly what I was looking for, thanks!
[Package] Generate AWS Signature V4 - Direct upload to S3
Hey guys.
I'm currently building a project which involves lot of file uploads and ofcourse, I did everything traditionally. The user uploads a file, I then upload it to my server and from there I send it Amazon S3. But it bothered me. Why do I need to make this useless, expensive trip to my server just to put it on Amazon S3 directly? There has to be a better way.
I did some research and saw that some file uploaders such as FineUploader offers the functionality to upload files directly to S3 - Great! However, it turns out that it's not that straight-forward. In order to upload directly to S3 you need to generate an AWS Signature V4 which requires to generate a policy for that and some form inputs. The thing is that everything has to be exactly as S3 wants it. For example, your policy contains an integer and not a string? god-forbid. You are going to face a 403 Access Denied with no explanation what's wrong or for some errors they are actually nice enough to return a 400 Bad Request with a line of description that may not be super useful.
So I started looking around to see if there are any existing libraries but couldn't find one until I came across a great post by Edd Turtle. So it seems he had figured this out and wrote a blog post about it.
I carefully examined his code and wrote an implementation that includes a little bit more functionality and most importantly, a bridge to Laravel. I call it Directo.
Thought it might be useful for others. Let me know what you think about this! :)
Please or to participate in this conversation.