How to upload a file to Amazon S3 and get the URL in response using iOS

I used the code snippet from the Amazon code sample. The following code loads data into an Amazon S3 bucket, but I need the url of the download file. Am I going in the right direction? or can someone point me to the mistake I'm making

Any help is appreciated.

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:

 bftask:<AWSS3TransferManagerUploadOutput: 0x1706606c0> { ETag = "\"0aefedfa36b687a74025b1ad50f3101f\""; serverSideEncryption = 0; } 
+6
source share
1 answer

If you just need to download the file, you can use AWSS3TransferManagerDownloadRequest to download the file using the SDK. Alternatively, you can use AWSS3PreSignedURLBuilder to create a pre-signed URL to download the file.

If you just want to know the URL of the object, the URL should look like this:

 https://<YourS3Endpoint>/<YourBucketName>/<YourObjectKeyName> 

Any objects in Amazon S3 are private by default and are not public. If you want to make it public, you need to set the ACL on your AWSS3TransferManagerUploadRequest object.

For more information, see Amazon S3 General Public Access Considerations .

+6
source

Source: https://habr.com/ru/post/986808/


All Articles