Has anyone successfully done this?
My idea is to post to a servlet and it will respond with Query String Request Authentication url after the servlet has authenticated the user. The user will then use this url to upload a picture file.
Was wondering if this is even possible.
The thing I don’t get is how do you transfer the picture from your computer or device to the s3.
This is the StringToSign:
PUT\n
(content here?)\n
image/jpeg\n
1175139620\n
/johnsmith/photos/puppy.jpg
How do I inser the content into the string to sign? Do i base64 it first then md-5 it?
Yes this is very much possible. You will only have to deal with how would like to send the URL back after creating the pre signed URL. Maybe as XML or as plain text..
I would recommend using the jets3t library to create the URL. You could call this API:
org.jets3t.service.S3Service.createSignedPutUrl(String, String, Map, Date, boolean)
You could also an IAM policy instead. But your way is easier.
Edit: Added more information..
That’s the beauty of it, when you are using the jets3t library you dont need to any of that.
Just call the method :
And use the URL to upload your image like below:
Edit for signedGetURL():
Only the ones with ProviderCredential being passed in are deprecated.. This one is not :
http://jets3t.s3.amazonaws.com/api/org/jets3t/service/S3Service.html#createSignedGetUrl(java.lang.String, java.lang.String, java.util.Date)
You wouldnt need to pass the credentials into this method anyway. Its only the s3service object that needs the credentials.. like this…