3

I'm using the v2 AWS iOS SDK to upload my images to the server my code i strait forward

 NSString * uniqueIdentifier = [[NSUUID UUID]UUIDString];

AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.bucket = @"my bucket";
uploadRequest.key = [NSString stringWithFormat:@"%@/images/%@.jpeg",objectId,uniqueIdentifier];
uploadRequest.ACL = AWSS3ObjectCannedACLPublicRead;

NSData * data = UIImageJPEGRepresentation(newImage, 0.8);

NSString *tmpDirectory = NSTemporaryDirectory();

NSString *tmpFile = [tmpDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpeg",uniqueIdentifier]];
NSLog(@"Temp File:%@", tmpFile);

[data writeToFile:tmpFile atomically:YES];

uploadRequest.body = [NSURL fileURLWithPath:tmpFile];

AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];

[[transferManager upload:uploadRequest] continueWithExecutor:[BFExecutor defaultExecutor]
                                                   withBlock:^id(BFTask *task) {
                                                       if (task.error != nil) {
                                                           NSLog(@"%s %@","Error uploading :", uploadRequest.key);
                                                       }else {

                                                           AWSS3TransferManagerUploadOutput * output = task.result;


                                                           NSLog(@"Upload completed %@",[output description]);


                                                       }
                                                       return nil;
                                                   }];

after i upload the file to the S3 Service where is the response URL? how do i know the url for that image? i want to put the image inside an object in by DB.

thanks

Janub
  • 1,594
  • 14
  • 26

1 Answers1

1

The publicly readable Amazon S3 objects follow this URL pattern:

https://S3Endpoint/BucketName/ObjectName

The easiest way to find out the URL of an object is to go to the AWS Management Console and look at the "Link:" for the object.

Yosuke
  • 3,759
  • 1
  • 11
  • 21