PinoyStackOverflower
PinoyStackOverflower

Reputation: 5302

Laravel S3 - File not found at path - when trying to move a file from a different directory in S3

I am trying to move an S3 file to a different directory in S3.

This is my code:

Storage::disk('s3')->move("https://my-s3-url.s3.aws.com/old-path/image.png","/new-folder/123/image.png");

The problem with this is I am getting this error:

League\Flysystem\FileNotFoundException  : File not found at path: https://my-s3-url.s3.aws.com/old-path/image.png

But, when I checked that file in the browser, that file really exists.

I am also certain that when I uploaded that file before, I used s3 as the Storage::Disk().

What seems to be the problem here? TIA!

Upvotes: 1

Views: 1856

Answers (1)

PinoyStackOverflower
PinoyStackOverflower

Reputation: 5302

I just realized my own mistake here.

I solved this by not putting the entire AWS S3 URL of the old URL. So instead of putting this:

https://my-s3-url.s3.aws.com/old-path/image.png

It should only be this: /old-path/image.png.

So my code looks like this:

Storage::disk('s3')->move("/old-path/image.png","/new-folder/123/image.png");

Hope this helps anyone.

Upvotes: 3

Related Questions