Amazon-S3 drive: move and copy not working with Laravel

Viewed 531

I am trying to write a function in my Laravel app that will rename a file on an S3 drive.

I have tried:

if(Storage::disk('s3')->exists($old_path)) {
    Storage::disk('s3')->move($old_path, $new_path);
}

but it does not do anything.

dd(Storage::disk('s3')->exists($old_path)) 

returns True

also

Storage::disk('s3')->put($full_path, file_get_contents($file));
Storage::disk('s3')->get($full_path);

both work fine!

1 Answers

The problem was down to the polices allowed for the resource in my S3 bucket.

To solve it I had to allow the following actions:

s3:GetObjectVersion

s3:DeleteObjectVersion

s3:PutObjectAcl

s3:GetObjectAcl

So my policy looks something like this now:

{
    "Effect": "Allow",
    "Principal": "*",
    "Action": [
        "s3:PutObject",
        "s3:PutObjectAcl",
        "s3:GetObject",
        "s3:GetObjectAcl",
        "s3:GetObjectVersion",
        "s3:DeleteObject",
        "s3:DeleteObjectVersion"
    ],
    "Resource": "arn:aws:s3:::folder/path/*"
}
Related