Confusing use of object_name in example for S3 upload using presigned URL #3986
Labels
documentation
This is a problem with documentation.
feature-request
This issue requests a feature.
p3
This is a minor priority issue
Problem
Please consider the following relevant parts of the example from generating-a-presigned-url-to-upload-a-file:
As far as I know (see e.g.
botocore
source), this hardcodes the object name'OBJECT_NAME'
into the pre-signed post's policy string.As a result, the filename that is supplied in the subsequent part of the example, i.e. the
{'file': (object_name, f)}
in the code below, is ignored. In other words, we could say{'file': ('something completely different', f)}
, but the object in our bucket would still be named'OBJECT_NAME'
.This is even more confusing if you consider the HTML form example that is provided at the bottom of the documentation page, which uses an
<input type="file">
to select a file, but the object name is already fixed, so the name of the selected file will be ignored.The result is a catch-22:
object_name
in order to generate the pre-signed postobject_name
, but that was already fixed in step 1Proposed solution
As can be seen in the
botocore
source, we canPerhaps it would be better to modify the example along these lines:
Specify a variable filename by adding
${filename}
to theobject_name
, as inthen specify a separate file name, to make the distinction clear
The HTML code can then remain unaltered, as the filename from the
file
input will be used properly.Links
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-presigned-urls.html#generating-a-presigned-url-to-upload-a-file
The text was updated successfully, but these errors were encountered: