I have started working on AWS recently. I am currently working on developing upload functionality to S3 storage.
As per my understanding there could be 2 ways to upload a file to S3:-
Client's file gets uploaded to my server and i upload this file to S3 server using my credentials. [i will also able to hide this from client as i will not be showing the upload details.]
Upload directly to S3
I was able to implement the first approach using simple upload api , but i want to skip the "write uploaded file to server disk" part and stream the content directly to S3 storage, while saving the upload details in my database. I also want to achieve the abstraction of AWS details. How do i do it ?? Please help. Thanks in advance
Try to use POST Object. You do not need to write any code to use it. See more detail in http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-UsingHTTPPOST.html
If you are not afraid of javascript, another opetion is Javascript SDK for S3. You can run it in browsers. http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/frames.html
Presigned url also works, you can generate the url either in browser (by javascript) or backend, and let the browser to send the request to S3 directly.
Create a cfg file on Linux server
And Save that file. Write the code in NetBeans. Also add libraries:
I am using using byte stream array to write file data to S3 object.
Code for servlet which is receiving uploaded file:-
Code which is uploading this data as AWS object:-
Note :- I am using aws properties file for credentials.
Hope this helps.