Sending pre-signed url in the response

This commit is contained in:
parth aranke 2024-06-02 06:47:18 +05:30
parent 8f73af8776
commit a2448bd0dc

View File

@ -32,10 +32,17 @@ def upload_to_s3(processed_data, userId):
# Upload the buffer to AWS S3
s3.upload_fileobj(buffer, BUCKET_NAME, s3_key, ExtraArgs={'ContentType': 'audio/wav'})
# Generate the URL of the uploaded file
file_url = f'https://{BUCKET_NAME}.s3.amazonaws.com/{s3_key}'
# Generate a pre-signed URL for the uploaded file
presigned_url = s3.generate_presigned_url(
'getObject',
Params={
'Bucket': BUCKET_NAME,
'Key': s3_key
},
ExpiresIn=3600 # URL expiration time in seconds (1 hour)
)
return file_url
return presigned_url
def int16_to_float32(samples):
return samples.astype(np.float32) / 32768.0