Add folder in Amazon s3 bucket

前端 未结 16 1378
青春惊慌失措
青春惊慌失措 2021-02-06 23:34

I want to add Folder in my amazon s3 bucket using coding. Can you please suggest me how to achieve this?

16条回答
  •  旧巷少年郎
    2021-02-06 23:45

    In iOS (Objective-C), I did following way

    You can add below code to create a folder inside amazon s3 bucket programmatically. This is working code snippet. Any suggestion Welcome.

    -(void)createFolder{
        AWSS3PutObjectRequest *awsS3PutObjectRequest = [AWSS3PutObjectRequest new];
        awsS3PutObjectRequest.key = [NSString stringWithFormat:@"%@/", @"FolderName"];
        awsS3PutObjectRequest.bucket = @"Bucket_Name";
        AWSS3 *awsS3 = [AWSS3 defaultS3];
        [awsS3 putObject:awsS3PutObjectRequest completionHandler:^(AWSS3PutObjectOutput * _Nullable response, NSError * _Nullable error) {
            if (error) {
                NSLog(@"error Creating folder");
            }else{
                NSLog(@"Folder Creating Sucessful");
            }
        }];
    }
    

提交回复
热议问题