New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deleting an external storage file #7960
Comments
I confirm same issue. To Reproduce:
What version of Directus are you using? |
I'm getting the same issue while also using DigitalOcean's Spaces storage. To reproduce:
What version of Directus are you using? What version of Node.js are you using? What database are you using? What browser are you using? What operating system are you using? How are you deploying Directus? |
This is still a problem for me. Any solution to this? |
I switched from DigitalOcean Spaces to Google Cloud Storage. Everything is working OK now |
I was still getting this issue but just resolved it by adding the ListBucket and ListBucketVersions permissions to my S3 bucket policy (although i don't think ListBucketVersions is necessary) List Bucket is used in node_modules/@directus/drive-s3/dist/AmazonWebServicesS3Storage.js Hope this helps!! |
I think there has been an update in this cold-case: #11641 Could you confirm the value used for ENDPOINT @calebyusuf? |
This still does not seem to work in 9.8 using S3 as storage adapter Deleting via the admin app or DELETE /files/:id rest api is successful (204) and removes the metadata in directus_files, but leaves the files in S3 |
@tarcon What AWS permissions are you using for the S3 bucket for the credentials used with Directus? |
The directus log with loglevel trace does not show an error while deleting files. My private bucket has disabled ACLs. I have not set up iam policies for the access. Files work fine, except for the deletion. Am I missing something? STORAGE_LOCATIONS: "s3", |
I'm assuming it's because the bucket might be configured to allow anybody to put files, but not delete files 🤔 |
We haven't been able to reproduce this so far.. For all the instances we've debugged, it has been due to access control rules in S3 itself (eg incorrect configuration for |
I believe that I have figured this out. I've been using Backblaze's B2 (S3 compatible) storage; I was getting the same problem. The short answer seems to be that S3 storage does not like relative paths. So, in @tarcon's example, change
to
This is what worked for me, at least. It might be worth updating the docs to reflect this. I also had the immediate thought that it was a permissions issue of some kind, but it is so much simpler than that! |
cc @erondpowell |
I can confirm this fixes my problem. Good job! |
Sorry for bringing attention to this again. I'm having the same issue as @tarcon. So, no error when deleting through Directus but it's not actually deleting any files in S3. But my I've confirmed the permissions allow for deletion of the image files with AWS's SDK. Directus .env STORAGE_LOCATIONS="aws"
## AWS S3
STORAGE_AWS_ROOT="/folder"
STORAGE_AWS_DRIVER="s3"
STORAGE_AWS_BUCKET="bucket-name"
STORAGE_AWS_REGION="us-east-1"
STORAGE_AWS_ENDPOINT="s3.amazonaws.com"
STORAGE_AWS_KEY="iam-user-key"
STORAGE_AWS_SECRET="iam-user-secret" AWS Policy Config {
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::bucket-name/folder/*"
} Any idea what I might be doing wrong? |
@chris-mcdonald-dev Mind opening a new issue? This one was marked resolved nearly exactly a year ago, which means that your problem is very likely caused by something else 🙂 |
Preflight Checklist
Describe the Bug
I have an external (S3) storage configured.
When delete a file (directus_files) from the Admin app/API, i expected the file to also get deleted from the external storage, just like it is for local files. But that didn't happen.
This would create a huge issue where there could potentially be thousands of orphan files left in the external storage bucket/folder attached to Directus.
To Reproduce
What version of Directus are you using?
v9.0.0-rc.92
What version of Node.js are you using?
16.5.0
What database are you using?
Postgres 12
What browser are you using?
Chrome
What operating system are you using?
Ubuntu
How are you deploying Directus?
Docker
The text was updated successfully, but these errors were encountered: