0

we have one functionality where we need to create an s3 bucket signed URL for the client. the client will upload a video on that URL.

we are using Boto version 2.38.0 for generating signed URL.

conn = boto.connect_s3()
key = "test_key"
bucket = "test_bucket"

signed_url = conn.generate_url(
    expires_in=600,
    method="PUT",
    bucket=bucket,
    key=key,
    headers={'Content-Type': 'application/octet-stream'}
)

I can upload the file with binary, but I can not upload the file with form-data. I have also tried multipart/form-data for the same. So, Could you please suggest me some request with signed URL video upload using POSTMAN?

Any help would be highly appreciated.

Thanks.

Nikunj
  • 33
  • 9

1 Answers1

1

You can use boto's build_post_form_args to obtain the HTML form data necessary to do a signed post request:

conn = connection.S3Connection(
    aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
    aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
)

data = conn.build_post_form_args(
    bucket_name=bucket_name,
    acl='public-read',
    storage_class=None,
    http_method="https",
)

You will get a dictionary containing form field names and values as well as a url to POST to.

Bernhard Vallant
  • 49,468
  • 20
  • 120
  • 148
  • Thanks, @Bernhard Vallant, will try this. – Nikunj Mar 29 '19 at 11:44
  • Thanks, @bernhard-vallant its working fine for me. I have just added few more parameters in **build_post_form_args** methods. those changes I will update here in a reply. but the S3 bucket uploading process is very slow. we have tested through Postman as well as using this API by integrating on a mobile application. so could you please suggest me any solution to overcome such an issue. – Nikunj Apr 02 '19 at 11:11
  • You can look into S3 Transfer Acceleration https://docs.aws.amazon.com/en_en/AmazonS3/latest/dev/transfer-acceleration.html#transfer-acceleration-getting-started – Bernhard Vallant Apr 02 '19 at 13:15