Regarding delete file via Parse.File on parse server side


I have a File on the parse server side, could I construct a Parse.File and delete it via Parse.File API?

Searched google and community and docs, seems did not find related info, what is the best practice doing this? Thanks!

If you have a parse file then you can use destroy method;

file.destroy({ useMasterKey: true });

It returns a promise. MasterKey is required for file delete operations.

If I only got the file path (local file), can I construct it to the Parse.File? thanks!

if you know the file name you can construct your parse file like this:

const file = new Parse.File(fileName);

If you have file path you can extract file name from path.

Thanks @uzaysan!

For the file, we are just upload it with simple plain multer module, no Parse.File involved, could this be OK?

A bit confused that what if I got two files with the same file name but just are under different folder?

İf you have a custom logic, you need to write your own deletion logic. Can you share how you save files?

@uzaysan Thanks for help. Code is something as below:

const storeStorage = multer.diskStorage(
    destination(req, file, cb) {
      cb(null, 'public/merchant/');
    filename(req, file, cb) {
      cb(null, file.originalname);
);'/uploadSingleFileForStoreList', multer({ storage: storeStorage }).single('file'), (req, res) => {
  console.log('uploadSingleFile.file', JSON.stringify(req.file));
  console.log('uploadSingleFile.body', JSON.stringify(req.body));

  res.send({ body: req.body, file: req.file });

Nihao, I would like to ask you a question, can I add your instant messaging software, and the email address is also ok
My email [email protected]

Looking forward to your reply

Hello @Rajon9 ,

You could send private message to me in this community, since I do not have instant messaging software, thanks.