last day (14 days later) » 

2:16 AM
1
A: Amazon S3 AWS upload image to a folder

Peter Pei GuoIt is all about how you structure your key. To put "filea" into "folderb", just name the key of the object as "folderb/filea".

 
not so clear can you please add some more description
 
when you form a put request, you give a bucket and a key, right? bucket is obviously morya as you stated. Now as for the key, you said your folder is testmorya, assume your file name is foo, then the key in this case is "testmorya/foo".
 
okay thanks let me test it.
Yeah thanks, it has been uploaded to folder, but i'm not able to get the URL where it has been saved, like it's saved here pastebin.com/wQAcHKkE (it contains the link). But what i'm getting back is is this pastebin.com/7ZxprPSP (it contains the link).
can you please help in this.
 
do you have access to the AWS console? you can find out the URL from there.
 
yes, i'm having access to console, but i need that URL to be saved at my other server. so that i can reuse it.
I need that URL to be reverted back to me so that I can save that url to my server and use it where ever i want to.
 
2:16 AM
go to the console, select the file and take a look at its properties. One of the property is link, and that's the url to use. But you also need to make your file has the correct ACL, so that it is available to the right audience.
did you find the link property?
 
yes i found it
it's set to private
can i specify the permissions for an object while putting it into bucket
 
see permissions section? open it up
yes, you can
it is called ACL, you can set when you upload
 
how can i set permission for an object progrmatically while uploading it to server
S3 AWS
you know any way>
?
 
try this:
 
what's there, there is nothing
 
2:26 AM
One sec, let me copy something from my code
 
okay
 
new PutObjectRequest(bucket, key, file).withCannedAcl(CannedAccessControlList.PublicRead)
this way, your request will include the correct ACL, in this case, make the file public for read
 
I'm testing it now
give me few
seconds
 
and have i used correct way of getting back the upload URL
ResponseHeaderOverrides override = new ResponseHeaderOverrides();
override.setContentType( "image/*" );
urlRequest = new GeneratePresignedUrlRequest( getString(R.string.s3_bucket), params[0].getName() ).withKey("testmorya/"+params[0].getName());
urlRequest.setResponseHeaders( override );
params here is file path
it worked like charm, it's set to public readable
 
2:32 AM
By lookign at it, i do not think you need the withKey, since the key is already in GeneratePresignedUrlRequest
Great!
Glad it worked for you!
 
but not getting the uploaded URL
here is the actual bucket url where image has been uploaded
ut what I'm getting is this
https:\/\/morya.s3.amazonaws.com\/testmorya%2FHello_113.jpg?response-content-typ‌​e=image%2F*&Signature=EPphAX1oHdKquN%2BYlvukdb20a2g%3D&Expires=1409453126&AWSAcce‌​ssKeyId=AKIAIKJPP2MIMSMGQLOA
so what i'm thinking is that I'll harcode this URL s3-ap-southeast-1.amazonaws.com/morya/testmorya/+filename
 
if you make it public, you do not really need the presigned url.
that works
 
thumbs up buddy, i really appreciate you any help you want just ping me here nitinmishra27@gmail.com
you helped me out than you.
 
I wrote down your email address. Thanks buddy, keep in touch. Mine is peterpeiguo@hotmail.com
 
i've written that also
 

last day (14 days later) »