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
Delete is not removing files from s3 bucket. #4
Comments
Could you post some example code of how you are deleting your model so I can attempt to replicate the problem? |
Hi achingbrain! thanks for the reply. delete: function(id, query, cb){
mongoose.model('posts').findByIdAndRemove(id, function(err){
if (err){
cb(null, err);
} else {
cb(null, 200);
}
});
},
I also tried implementing the image delete myself but there seems to been an open issue with knox. so im guessing that is where the failure may be coming from? Here is what i tried. postsSchema.post('remove', function(post){
var img = post.image;
var org = img.original.url.substring(img.original.url.match('/images').index);
var md = img.medium.url.substring(img.medium.url.match('/images').index);
var sm = img.small.url.substring(img.small.url.match('/images').index);
S3Client.deleteMultiple([org, md, sm], function(err, res){
if (err){
console.log(err);
} else {
console.log(res);
}
});
}); Im hoping this might be an aws configuration issue. |
Middleware hooks aren't run when using See the note towards the bottom of Mongoose's
|
Still having the same issue. Post.remove({_id: id}, function(err, post){
if (err){
cb(null, err);
} else {
cb(null, 200);
}
}); |
Hmm, I'm not sure. According to remove() there is again a note stating:
But that seems contradictory to what I see happening in Crate's tests; perhaps I'm reading the docs wrong. One thing of note, and probably unrelated, is that in your examples you're passing along the Post.remove({_id: id}, function (err, post){
if (err) return cb(err);
cb(null, 200);
}); |
Maybe it's only on instances..? Post.findById(id, function (err, post) {
if (err) return cb(err);
post.remove(function (err) {
if (err) return cb(err);
cb(null, 200);
});
}); |
@rgruesbeck did you ever find out what was wrong? I haven't been able to replicate this issue, and I even started uploading files to S3 for real in the mongoose-crate-s3 tests. |
Closing due to lack of response. @rgruesbeck please re-open if you come back to this. |
I can also confirm this issue. Here's my function for deleting a user:
My model is defined as:
When I make a call to my delete function, the model gets removed but the images remain on S3. |
Hi, my image files are not being deleted along with the model.
my model and crate config look like this.
The text was updated successfully, but these errors were encountered: