Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Problem with updates and deletes #24

Open
gabicasas opened this issue Jun 11, 2017 · 6 comments
Open

Problem with updates and deletes #24

gabicasas opened this issue Jun 11, 2017 · 6 comments

Comments

@gabicasas
Copy link

Hi,
I am newbie with nodejs, so I dont understand my problem.
When I create a new document that contains a s3 file all is ok but if I modify this document ( I modify the file) or I delete the document the associated file dont dissapear over S3.

Whats happen? Configuration problem? Any suggest?

Excuse me for my bad English. Thanks in advise

@jacobvr
Copy link

jacobvr commented Sep 13, 2017

+1 problem exists. Uploading file adds it to s3 bucket, but deleting file from keystone is not deleting it from s3 bucket.

@PhilCuster
Copy link

PhilCuster commented Feb 15, 2018

For future reference, until this problem is fixed it is best to use a post-hook to delete it manually. Something like this should do the trick:

Image.schema.post('remove', function (doc) {
    // Delete the file from the your adapter here.
    
});

@Avcajaraville
Copy link

Yeah, this is very problematic for my current set up.

On remove hook, is all fine, but what if trying to delete an image when editing a post ?

In that case, the updateItem method of FileType is call, and no way of hooking there, so I cant delete my images on S3... :(

@internetErik
Copy link

I'm trying to delete a file when it is removed or switched, and not only when the entire document is deleted. I know I can use a pre save hook to get an opportunity to delete the file, but I need the old value. I was thinking that I could get the old value by storing it while in a setter, but this hasn't worked.

Document.schema.path('file.filename').set(function(newVal) {
  this._oldFileFilename = this.file.filename;
  return newVal;
});

Before I include this setter, it seems that the filename is added on the object as normal, but with the setter it is no longer added. Is my setter perhaps conflicting with one added by this project? (I haven't looked into this yet, I was wondering if anyone else has tried this).

@bish0p86
Copy link

This is still an issue or am I missing something? I cannot remove images from S3 at all... As mentioned above it removes db entry but does not fire S3Adapter.prototype.removeFile any suggestions?

@conghai
Copy link

conghai commented Oct 15, 2018

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants