I followed filepond doc about Setting Initial Files to prepopulat filepond. Now, I want to write a custom revert function in which I can use different function based on file origin.
The following is a hypothetical code to show what I want to achieve:
#hypothetical code
revert: (uniqueFileId, load, error) => {
console.log('uniqueFileId is +' uniqueFileId);
const origin = ? ; //cannot figure out how to get file origin.
if (origin =='1'){ // origin is input
// run default function to remove input file
} else if (origin =='2'){ // origin is limbo
// run custom function to remove limbo file from server
});
} else { // origin is local
// run custom function to remove local file from server
}
error('oh my goodness');
// Should call the load method when done, no parameters required
load();
},
Question 1: I cannot get origin of the file. I tried following code inside of revert function, none of them worked. How should I get the origin of the file?
const origin = origin;
console.log('origin is ' + origin); // console not printing anything, no error message.
const origin1 = FilePond.getFile().origin;
console.log('origin1 is ' + origin1);// console not printing anything, no error message.
Question 2: suppose i can get origin of the file, how should I write function to remove input file? (in the origin == 1 case)? One thing I found was that when I click cancel button on newly added file, the uniqueFileId was 'success'. I am not sure if this is the way it should be because the file hasn't been uploaded or I have done something wrong.
In the case of 'LIMBO', the uniqueFileId was correctly shown as the file name such as '1.jpg'. I was able to pass this Id to the server.