pqina / filepond-plugin-file-rename

🏷 File rename plugin for FilePond
MIT License
6 stars 3 forks source link

How to use this plugin ? #1

Closed laurent-d closed 6 years ago

laurent-d commented 6 years ago

Hi @rikschennink ! This plugin looks promising, but how can we use it if we use multiple inputs : how retrieve the good filepond instance ? Can we set attribute on the input like the accept plugin ? Thanks for you work

rikschennink commented 6 years ago

Hi @laurent-d , I totally forgot to document it :-)

Something like this should work:

FilePond.setOptions({
    fileRenameFunction: (file) => {
        // file contains a basename, extension and name (which is basename plus extension)
        // return the new name, here we prepend some text and append some text
        return `prepended_${ file.basename }_appended${ file.extension }`;
    }
});
rikschennink commented 6 years ago

I've updated the docs with a quick example: https://pqina.nl/filepond/docs/patterns/plugins/file-rename/#usage

laurent-d commented 6 years ago

Thanks a lot ! Do you think you can concider the developpement for using filename attributes to set desired name with multiple instance of filepond and different forced filename ? I have tried to take the exemple of validate type plugin but some part of it are very blurry to me..

rikschennink commented 6 years ago

If you have multiple instantances you can pass each instance a unique function. The example above sets a generic function for all instances to use.

laurent-d commented 6 years ago

Thanks !