Question:
I have used the code snippet from Amazon Sample Code. The below code uploads the data into amazon S3 bucket, but I need the URL of the upload file. Am i going in the right direction? or could someone point me the mistake I am making
Any kind of help would be greatly appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager]; AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new]; uploadRequest.bucket = S3BucketName; uploadRequest.key = S3UploadKeyName; uploadRequest.body = self.uploadFileURL; //uploadRequest.contentLength = [NSNumber numberWithUnsignedLongLong:fileSize]; [[transferManager upload:uploadRequest] continueWithBlock:^id(BFTask *task) { // Do something with the response AWSS3TransferManagerUploadOutput *uploadOutPut = task.result; NSLog(@"bftask:%@",uploadOutPut); // Upload out put gives me the following response return nil; }]; |
bfTask Response:
1 2 3 4 5 |
bftask: ETag = "\"0aefedfa36b687a74025b1ad50f3101f\""; serverSideEncryption = 0; } |
Answer:
If you just need to download the file, you can use AWSS3TransferManagerDownloadRequest
to download a file using the SDK. Alternatively, you can use AWSS3PreSignedURLBuilder
to generate a pre-signed URL to download a file.
If you just want to know the URL of the object, the URL follows the following pattern:
1 2 |
https:// |
Any objects in Amazon S3 are private by default and not publicly readable. If you want to make it publicly readable, you need to set ACL
on your AWSS3TransferManagerUploadRequest
object.
See Amazon S3 Bucket Public Access Considerations for more details.