@filerobot/xhr-upload
TypeScript icon, indicating that this package has built-in type declarations

3.32.17 • Public • Published

@filerobot/xhr-upload

Plugins Website Version Scaleflex team License CodeSandbox

Filerobot Widget logo

The XHR upload plugin for Filerobot Media Asset Widget handles uploading files in Multipart form uploading way and HTTP(s) protocol.

Usage

NPM

npm install --save @filerobot/xhr-upload

YARN

yarn add @filerobot/xhr-upload

then

import XHRUpload from '@filerobot/xhr-upload'
...
...
...
filerobot.use(XHRUpload, propertiesObject)

CDN

The plugin from CDN is found inside Filerobot global object Filerobot.XHRUpload

const XHRUpload = window.Filerobot.XHRUpload
...
...
...
filerobot.use(XHRUpload, propertiesObject)

Properties

uploadToFolderPath

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 the uploadQueryParams if you want to use this property or uploadQueryParams will override this property's value.

uploadQueryParams: string

Type: string.

Default: ''

The query to be appended to the upload url, ex. ../upload?extra=hello&foo=bar.

limit

Type: number.

Default: 0

Limit the number of uploads' requests handled at the same if left 0 then there is no limit.

timeout

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.

headers:

Type: object.

Default: {X-Filerobot-Key: '...'}

If you want to customize the headers of the upload requests are being sent to the backend.

info

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

addInfoCallback

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

meta

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

locale

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @filerobot/xhr-upload

Weekly Downloads

836

Version

3.32.17

License

MIT

Unpacked Size

91.7 kB

Total Files

6

Last publish

Collaborators

  • philipka
  • amrw.js
  • amr26
  • ahmeeedmostafa
  • vitaly.shaposhnik