0

I'm trying to implement revert function but have an issue

revert(uniqueFileId, load, error) {
        const desertRef = this.storage.ref().child(uniqueFileId);
        desertRef.delete().then(function () {
          const index = self.files.indexOf(uniqueFileId);
          if (index > -1) {
            self.files.splice(index, 1);
          }
          load();
        }).catch(function (e) {
          switch (e.code) {
            case 'storage/canceled':
              break;
            default:
              error(e.message)
          }
        });
      },

full source https://gist.github.com/boskiv/dd299cebcec4ca9ef8b8d792c7b4a420

In this case uniqueFileId in revert function contain full URL from storage.(https://firebasestorage.googleapis.com/v0/b/koko-date-dev.appspot.com/o/gifts%2FhfvhV6Iou15pBj1mhA8b)

Is there option to get just filename in that case without complex parsing and string split

this in revert function this in revert function

this in process function this in process function

BoSkiv
  • 801
  • 8
  • 12

1 Answers1

1

The uniqueFileId is the string passed to the load callback inside the process function. So if you’re sure the name is unique you can pass the file name there and it should appear in the revert method.

See: https://pqina.nl/filepond/docs/patterns/api/server/

Rik
  • 3,328
  • 1
  • 20
  • 23