The XHR upload plugin for Filerobot Media Asset Widget handles uploading files in Multipart form uploading way and HTTP(s) protocol.
npm install --save @filerobot/xhr-upload
yarn add @filerobot/xhr-upload
then
import XHRUpload from '@filerobot/xhr-upload'
...
...
...
filerobot.use(XHRUpload, propertiesObject)
The plugin from CDN is found inside Filerobot
global object Filerobot.XHRUpload
const XHRUpload = window.Filerobot.XHRUpload
...
...
...
filerobot.use(XHRUpload, propertiesObject)
Type: string
.
Default: null
The path of the folder that will be used in uploading to, if this property is provided it will override the current opened folder path and files would be uploaded to this path.
Note: you shouldn't provide
folder=...
in theuploadQueryParams
if you want to use this property oruploadQueryParams
will override this property's value.
Type: string
.
Default: ''
The query to be appended to the upload url, ex. ../upload?
extra=hello&foo=bar
.
Type: number
.
Default: 0
Limit the number of uploads' requests handled at the same if left 0
then there is no limit.
Type: number
.
Default: 60 * 1000
Defines the timeout for not receiving upload events or having no uploading's progress after that amount of milliseconds it abort the upload assuming there is a problem with the connection, if set to 0
this feature will be disabled.
Type: object
.
Default: {X-Filerobot-Key: '...'}
If you want to customize the headers of the upload requests are being sent to the backend.
Type: object
.
Default: undefined
If you want to pass some info to the file pass an object with the needed info to this property and it would be considered while uploading the file, example: { recipe_id: 10 }
.
Note: Applied only for local uploads
Type: function
.
Default: undefined
If you want to pass some info to the file after doing some operation/functionality, pass a function that has file
object as a parameter that contains the file's details and returns an object of the info data to be passed and saved to the file while uploading otherwise the function won't be considered.
Example, (file) => (file.name === 'first' ? { file_order: 'first' } : false)
Note: Applied only for local uploads
Type: object
.
default: undefined
Add some meta in the file object by providing the meta as object to this property , example: { recipe_category: 'Vegetables' }
.
Note: Applied only for local uploads
Type: object
.
Default:
{
strings: {
timedOut: 'Upload stalled for %{seconds} seconds, aborting.'
}
}
Customizing some of the translations or the language's strings and replace the default locale.