I'm unable to delete a file in my bucket after updating my team-based permissions.
- Create a team and give it
create
,read
, andupdate
permissions to a bucket - Upload multiple files by using
storage.createFile()
- Delete one of those files by using
storage.deleteFile()
- you should get an error here about not having the permission to delete the file - Add the
delete
permission to the team you created on step 1 - Try deleting the file again and you'll still get an error
I keep getting an error when I attempt to delete a file after giving the team I belong to delete
permissions.
If I delete the file from the console this is what I get:
{
"message": "Server Error",
"code": 500,
"type": "general_server_error",
"version": "1.3.8"
}
If I attempt to open the file, this is what I get:
{
"message": "File not found in \/storage\/uploads\/app-<ID>\/<ID>\/<ID>.jpg",
"code": 404,
"type": "storage_file_not_found",
"version":"1.3.8"
}
NOTE: This only happens to the file I had the error on when I didn't have the delete permission. I was able to successfully delete the other files that I didn't try to delete before adding the delete
permission.
When you got the 500 error, what was the docker logs for the appwrite container related to that 500 error
Did you create and delete the files using a client SDK?
Was file security enabled?
I'm done working on the project today so I'll take a look at the logs tomorrow.
Yes it was created using a client SDK (web). The first delete attempt (when I got the error) was done via the client SDK as well. However, after I added the delete permission to the team I belong to, I only tried deleting the file from the console.
File security is disabled and I'm doing bucket-level permissions.
[Error] Timestamp: 2023-08-27T01:25:41+00:00
[Error] Method: DELETE
[Error] URL: /v1/storage/buckets/:bucketId/files/:fileId
[Error] Type: Appwrite\Extend\Exception
[Error] Message: The current user is not authorized to perform the requested action.
[Error] File: /usr/src/code/app/controllers/api/storage.php
[Error] Line: 1426
[Error] Timestamp: 2023-08-27T01:26:40+00:00
[Error] Method: DELETE
[Error] URL: /v1/storage/buckets/:bucketId/files/:fileId
[Error] Type: Appwrite\Extend\Exception
[Error] Message: Failed to delete file from device
[Error] File: /usr/src/code/app/controllers/api/storage.php
[Error] Line: 1436
The first DELETE
was when I attempted to delete the file using the client SDK (web) - this was back when I didn't have the delete
permission granted to the team I belong to.
The second DELETE
was after I added the permission to the team I belong to - but I only tried to delete the file from the console at this point.
@joeyouss would you please try to reproduce this?
Yep, here is the github issue: https://github.com/appwrite/appwrite/issues/6042
Fyi, what could be happening is the actual file gets deleted from the device, but maybe there's a bug with the internal document for the file and that fails to get deleted. Then, the file ends up in an inconsistent state where the actual file is gone, but Appwrite's metadata for the file is still there
Yeah I commented the same thing but this shouldn't be happening
Well see once you try to reproduce it. We can debug if we can reliably reproduce the problem
Looks like there was a permission bug. Hopefully this fix will be fixed in 1.4.2: https://github.com/appwrite/appwrite/pull/6102
Recommended threads
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- Custom Domains
Hi All, Should be a quick config issue. I'm setting up custom domains on the hosted version. I have verified the domain with the CNAME but appwrite isn't gene...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...