hope all is well. I am trying to upload a file that is situated in my s3 bucket to another bucket. However, I want to use a lambda function to upload it to another bucket using s3 presign URL as I want it to have an expiration feature in the new bucket. I passed the object file URL as key when uploading to destination bucket but does not seem to work. Some guidance would be appreciated.
import json
import time
import boto3
s3= boto3.client('s3')
time.sleep(10)
bucket_name_file='mybucketname'
#fetch last modified item from bucket
response = s3.list_objects_v2(Bucket=bucket_name2)
all = response2['Contents']
latest = max(all, key=lambda x: x['LastModified'])
my_file_name=latest['Key']
url_of_my_filename='https://' bucket_name_file '.s3.amazonaws.com/' my_file_name
###################################################
destination_bucket_to_send='my_destination_bucket'
url=s3_client.generate_presigned_url('put_object',
Params={'Bucket': destination_bucket,
'Key':url_of_my_filename,
},
ExpiresIn=20000)
CodePudding user response:
It would appear that your goal is to use Amazon Translate to translate some text via a Transcription Job. You then want to offer the resulting translation via a temporary URL.
To accomplish this, you can create an Amazon S3 pre-signed URL on the object that was created by the transcription job. This URL can then be used from the Internet to obtain the translation. Once the expiry period has passed, the URL will no longer provide access to the object.