-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
s3Adapter: Deleting objects and their attached files? #643
Comments
@globyworks this is a behaviour that was originally there on parse.com. And no further effort was done to delete the files. I recall there was a button to delete orphelin files, we could as well provide an endpoint for that. In the meantime, you can query all your objects, collect all the files, then query S3, check which ones are in extra, and delete those ones. That would be the way. |
If you want to delete files when deleting an object, you could use an afterDelete hook. You could either trigger the rest api delete endpoint for the file, or access the file adapter directly to delete the file from s3. |
@gfosco can you provide sample code about how to use the S3Adapter to delete a file in cloud code? |
@globyworks when your files are saved to your s3 bucket, are they also saved in your MongoDB database? Is there a way to replace the file in my MongoDB database with a URL to the file in s3? |
If the files are saved to S3, they should not /can't be saved in the local database |
Ok, I'll have to look into it more. I'm on Heroku with MongoLab and when I open my MongoLab db, I can still see an entry called [filename].m4a. But I just noticed the file size for the Class doesn't go up as much as the .m4a file size when I save. Thanks. |
@lususvir using my config, files are uploaded to Parse Server where they get redirected to the S3 bucket. Then the file name is saved on MongoDB and it gets attached to the path to that bucket when needed. |
for anyone in need of a straightforward explanation - connected s3 with Bucketeer add on (a little simpler and less config than otherwise, I am not comfortable enough w/ AWS manipulation). also had to make sure that my parse-server dependency was updated enough to include the s3 router. if you're new to terminal, fyi you can create a JS file on the main dir and then heroku run node filename.js after pushing the project per changes You obv have to be sure that this is the only reference to that file, or that you are deleting those other relevant references when you delete the file from the bucket. |
pasting working code example here after spending a day on it. I have a class called "classContainingFileAttr" which contains a column "pfFilecolumn" that's of PFFile type. When I delete that class object on Parse server, the file still exists in S3, so I would like to delete that orphaned file in order to save space. in packages.json, add the following: in main.js, add the following: AWS.config.update({ function deleteS3File( fn ) { // clean up orphaned file on S3 |
I've used fs-store-adapter to save files on disk. please provide sample cloud code to delete files from disk after deleting parse object too |
here is the fsadapter cloud code:
|
Hello, based on @jenlai1345 's answer and many others. DISCLAIMER : QUESTION:
Code :
|
Thanks @jenlai1345 Here is the code for Gcloud:
|
Hi all.
I have now configured my Parse server to use an S3 bucket to store files.
While this is working great (on PHP. iOS) create and store an object, when i try to delete the object, object is deleted from Mongo but the file assocciated with it, is still in my S3 bucket.
What is need is, when i delete an object from Mongo, all files attached to it to get deleted too (from s3).
Any ideas how to do that?
thnx
The text was updated successfully, but these errors were encountered: