Ghosts in my App, particularly one collection. Data randomly removes itself

I built an application recently for a yacht listing site. Ever since launch there has been strange occurrences where images uploaded to Cloudinary and their corresponding data to the database suddenly vanishes. They do not vanish right away, say I upload an image to Cloudinary and store its response in our database for further use.

But after a couple days, randomly some of the stored data will vanish from the database and Cloudinary alike. I contacted Cloudinary support and they say the the images were deleted from using the Node JS SDK (I’m assuming Meteor) method.

I have no cron jobs and the user says he never deletes them, the call to delete things is protected by if the user is logged in or not. I am pretty baffled as I have never ran into this issue before on any other Meteor build.

Ideas?

I have temporarily disabled any calls to remove images to narrow down the issue. Hopefully it is not something malicious.

Are you using a cloudinary package from atmosphere? If so, which one?

I am https://github.com/Lepozepo/cloudinary, the call to my delete method looks like this. You can see it removes the image first then the database. Somehow, I think this is getting triggered?

'click .delete-media' (event) {
        event.preventDefault();
        if (Meteor.userId()) {
            let id = this._id,
                confirm_delete = confirm('Delete this image?');

            if (confirm_delete) {
                return Cloudinary["delete"](this.filename.public_id, function(err, res) {
                    if (err) {
                        console.error(err);
                        notify('Deletion Error', 'Something went wrong while deleting the image from Cloudinary.', 'Deletion Error', 'rgba(172,41,37, 0.8)');
                    }

                    Meteor.call('imageDelete', id, function(err) {
                        if (err) {
                            console.error(err);
                            notify('Deletion Error', 'Something went wrong while deleting the image from the Database.', 'Deletion Error', 'rgba(172,41,37, 0.8)');
                        } else {
                            let deletePrompt = document.querySelectorAll('.delete-prompt');
                            for (let i = 0; i < deletePrompt.length; i++) {
                                deletePrompt[i].style.display = "none";
                            }
                            notify('Image Deleted', 'Your image has been deleted.', 'Image Deleted', 'rgba(57,132,57, 0.8)');
                        }
                    });
                });
            }
        }
    }

Have you setup the delete rule for cloudinary?

I have not… Can you tell me what you men please.

That package requires rules to be set up to disallow certain tasks, one of them being deleting images from cloudinary.

// On the server
Cloudinary.rules.delete = function(userId, publicId) {
    if("you want to allow delete"){
        return true;
    } else if ("you want to deny delete") {
        return false;
    }
}
2 Likes

Ah , ok I didn’t see that in the docs.

Public Id is referring to the image public id correct?

Correct.