Closed mfn closed 4 months ago
Maybe not a "software bug", but sure an inconsistency well hidden. Maybe this is documented (or: should be)?
Hi @mfn, we have merged the following PR that url decodes the Location
when the upload is done through a multipart request.
Please feel free of opening a new issues for anything else that we may help with.
Thanks!
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
Describe the bug
There's a pretty interesting surprise behaviour in getting back the canonical URL of the just-uploaded data.
If the file size exceeds
\Aws\S3\ObjectUploader::DEFAULT_MULTIPART_THRESHOLD
, then a different upload strategy is used, which ends up returning a differently encodedObjectURL
: for such files, e.g./
is encoded as%2F
, possibly breaking certain assumption on what is supposed to be returned here.Expected Behavior
The returned
ObjectURL
should be consistent, i.e. uploading the 17mb file should output:Current Behavior
The
ObjectURL
is encoded differently, based on the file size.Reproduction Steps
Test script:
Test files created:
Uploading the 15mb file:
Uploading the 17mb file (notice the
%2F
in the path‼️):Possible Solution
The returned value should be consistently encoded.
In
\Aws\S3\PutObjectUrlMiddleware::__invoke
, theObjectURL
is "constructed":As can be seen, in case of
CompleteMultipartUpload
, which is used for data > 16MB, the resultingLocation
is used, which AFAICS, is from the header response directly.For regular uploads,
ObjectURL
is based on$result['@metadata']['effectiveUri']
, which itself is created in\Aws\WrappedHttpHandler::parseResponse
asI.e. it's constructed from the internal
$request
object, instead of the returned server response.Additional Information/Context
No response
SDK version used
3.308.7
Environment details (Version of PHP (
php -v
)? OS name and version, etc.)PHP 8.3.7, Linux