S3Client: upload()
returns differently encoded ObjectURL
, depending on the uploaded file size (e.g. %2F
instead of /
)
#2933
Labels
bug
This issue is a bug.
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 pathPossible 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
The text was updated successfully, but these errors were encountered: