Skip to content

File uploads to DigitalOcean Spaces broken in AWS SDK 3.359.12 (works in 3.337.2) #3218

@saqlainkhadim

Description

@saqlainkhadim

Describe the bug

this is writen in my composer.json "aws/aws-sdk-php": "^3.252", in laravel project
and i run composer update.
earlier in composer.lock "aws/aws-sdk-php": "3.337.2",
and now i saw at composer.lock there is 3.359.12
and here is my code

public function store(Request $request)
 {
     $request->validate(
         [
             'media' => 'nullable|file|image|max:2048|required_without:url',
             'url'   => 'nullable|url|max:2048|required_without:media',
         ],
         [
             'media.required_without' => 'Media or URL is required.',
             'url.required_without'   => 'Media or URL is required.',
         ]
     );
     $file = $request->file('media');
     $accountId = currentAccountId();
     $name = '';
     if($file){
         $name = $file->getClientOriginalName();
         $path = $file->store('gallery/account_' . $accountId, 'spaces');
         $url = Storage::disk('spaces')->url($path);
     }else{
         $name = basename(parse_url($request->url, PHP_URL_PATH));
         $url = $request->url;
     }
     $image = Image::create([
         'name' => $name,
         'path' => $path ?? null,
         'url' => $url,
         'account_id' => $accountId,
         'external_src' => $file ? false: true, // if file is received from request then it is not external
     ]);
     return ok(compact('image'), true);
 }

this code was working ealier now this code stoped working with this error message


Unable to write file at location: gallery/account_21370/kGiQ63cHWOVxZf3N5FYZ81D4QArbckcZf98UNnO9.jpg. Error executing "PutObject" on "https://nyc3.digitaloceanspaces.com/gallery/account_21370/kGiQ63cHWOVxZf3N5FYZ81D4QArbckcZf98UNnO9.jpg"; AWS HTTP error: Client error: `PUT https://nyc3.digitaloceanspaces.com/gallery/account_21370/kGiQ63cHWOVxZf3N5FYZ81D4QArbckcZf98UNnO9.jpg` resulted in a `404 Not Found` response:
<?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Mess (truncated...)
 NoSuchBucket (client): The specified bucket does not exist - <?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><Resource>gallery/account_21370/kGiQ63cHWOVxZf3N5FYZ81D4QArbckcZf98UNnO9.jpg</Resource><RequestId>not available</RequestId></Error>

error is solve with by locking version but what is best solution

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

upload file to digital ocean

Current Behavior

throws error

Reproduction Steps

i just did composer update

Possible Solution

lock package version

Additional Information/Context

No response

SDK version used

3.359.12

Environment details (Version of PHP (php -v)? OS name and version, etc.)

8.2.21

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.response-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions