Store the file object using a form post.
The FormPostStore extension can be configured with the FormPostStoreOptions object.
import { defineFilePond } from 'filepond';
import { locale } from 'filepond/locales/en-gb.js';
import { FormPostStore } from 'filepond/extensions/form-post-store.js';
defineFilePond({
locale,
extensions: [
// Add the FormPostStore extension and configure with FormPostStoreOptions object
[FormPostStore, {
// Where to post files to
url: './upload'
}]
]
})
Server configuration
This section outlines how the FormPostStore extension communicates with our server. The request and response format can be manipulated with the resolveRequest and resolveResponse hooks.
Storing files
The extension will POST individual files as multipart/form-data to the supplied url, the name used for the field can be configured using the name option.
The server is expected to return a plain/text response containing the id of the file on the server.
Restoring files
It will restore file entries by calling the supplied url with a GET request and appending the file server id url?id=FILE_SERVER_ID.
The server is expected to return a file object.
When fetchMetadata is true the extension first fires a HEAD request to request file information. This makes it possible to show file metadata before the file has been fully downloaded.
Releasing files
When a file is stored, clicking the revert button should remove the previously uploaded file. The extension fires a DELETE request appending the file server id to the url like so url?id=FILE_SERVER_ID.
This currently is a fire and forget operation, the server can respond with 200 OK