java - creating a folder/uploading a file in amazon S3 bucket using API -


i total newbie amazon , java. trying 2 things here.

1st - trying create folder in amazon s3 bucket have created , have got credentials for.

2nd - trying upload file bucket.

as per understanding can use putobjectrequest() method acheiving both of tasks.

putobjectrequest(bucketname, keyname, file)  

for uploading file.

i not sure if should use method

putobjectrequest(string bucketname, string key, inputstream input,         objectmetadata metadata)  

for creating folder. struggeling inputsteam , objectmetadata. don't know , how can use it.

any appreciated. :)

yes, can use putobjectrequest(bucketname, keyname, file) achive both task.

1, create s3 folder
aws s3 java sdk , add "/" @ end of key name, create empty folder.

var folderkey =  key + "/"; //end key name "/" 

sample code:

final inputstream im = new inputstream() {       @override       public int read() throws ioexception {         return -1;       }     };     final objectmetadata om = new objectmetadata();     om.setcontentlength(0l);     putobjectrequest putobjectrequest = new putobjectrequest(bucketname, objectname, im, om);     s3.putobject(putobjectrequest); 

2, uploading file similar, can input stream local file.


Comments