Nebulous Program Mechanic

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

    1.0.128-alpha.6 • Public • Published

    @filerobot/xhr-upload

    The XHR upload plugin handles uploading files in Multipart form uploading way and HTTP(s) protocol.

    Usage

    From NPM

    The plugin is on NPM as @filerobot/xhr-upload

    npm install --save @filerobot/xhr-upload

    then

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

    From CDN

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

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

    Options

    locale: object (optional)

    default:

    {
      strings: {
        timedOut: 'Upload stalled for %{seconds} seconds, aborting.'
      }
    }

    Customizing some of the translations or the language's strings and replace the default locale.

    uploadToFolderPath: string (optional)

    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 (optional)

    default: ''

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

    limit: number (optional)

    default: 0

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

    timeout: number (optional)

    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: object (optional)

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

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

    info: object (optional)

    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: function (optional)

    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 detials 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: object (optional)

    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

    Keywords

    none

    Install

    npm i @filerobot/xhr-upload

    DownloadsWeekly Downloads

    521

    Version

    1.0.128-alpha.6

    License

    MIT

    Unpacked Size

    43.1 kB

    Total Files

    5

    Last publish

    Collaborators

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