David
David

Reputation: 329

Android and AWS S3

i am creating an Android App within AWS mobile Hub, i would like to do know is it possible when a user Signs up to my Application that an S3-Bucket or even a Folder within an S3 bucket is created only for that user account ?

Upvotes: 0

Views: 131

Answers (1)

Piyush Patil
Piyush Patil

Reputation: 14523

Yes, you can use PutObjectRequest(bucketName, keyName, file) to achieve your use case.

Create S3 folder

With AWS S3 Java SDK , just add "/" at the end of the key name, it will create empty folder.

var folderKey =  key + "/"; //end the key name with "/"

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);

Upvotes: 1

Related Questions