Hi,
According to the docs, it says:
When a Media-object gets deleted the package will delete its entire associated directory. To avoid tears or worse, make sure that every media gets stored its own unique directory.
I tried it (my filesystems is S3) and what happens is only the file get deleted. the associated id folder doesn't get deleted. It becomes an empty folder instead (i.e. folder 123 for media id 123 still exist but empty)
What did I do wrong?
Thank you.
I think this is a bug, i'd accept a PR that fixes this.
The same issue is on Azure - I beliefe that this is related to the blob-storage and that they don't know directories but Filesystem::getMediaDirectory() creates the directory - in blob storages this will result in a normal blob.
The error is here that it only excludes the driver name if it's s3. So it doesn't exclude by the driver or does it exclude other blob storages.
https://github.com/spatie/laravel-medialibrary/blob/cd121dfc4f361324e897d894b574f4bc4fe481c3/src/Filesystem/Filesystem.php#L202-L204
I just tested this issue with my s3 and looks like working fine.
@webcrazy what's the name of your filesystem S3 storage? Is it s3 like the driver or something else?
@Gummibeer laravel media library driver s3
inside .env file
MEDIA_DISK=s3
what is the iam policy you used?
@ziming AmazonS3FullAccess
@webcrazy could you change the name of your storage to something else and try if it still deletes the "folder"?
@Gummibeer I'm sorry. Did you mean s3 bucket name?
@webcrazy no I mean the name of your filesystem storage in the Laravel config.
So in the config/filesystems.php.
@Gummibeer I changed it to local, tested with a few images and still working it fine.
This is my IAM policy attached to my aws user if it helps. Did I miss out on anything?
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1420044805001",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:ReplicateObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::bucket-name",
"arn:aws:s3:::bucket-name/*"
]
}
]
}
Thank you
I just tested this, and it seems to work for me. I guess your experiencing the issue because of a permission problem on S3.
@freekmurze I can confirm it is not a permission issue as I did not went back to change my S3 bucket policy. However some weeks or months after I posted this. The delete started working again
So most likely what happened is that 1 of the future updates after my issue post fixed it. So either way it can be closed :).