npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@filerobot/xhr-upload

v3.41.14

Published

Plain and simple classic HTML multipart form uploads with Filerobot Media Asset Widget, as well as uploads using the HTTP PUT method.

Downloads

4,125

Readme

@filerobot/xhr-upload

Plugins Website Version Scaleflex team License CodeSandbox

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)

Example

You can use upload in two ways:

  • By using Progress Panel plugin, please check the example there.
  • By using widget events, please check how to use events here and see the example below:
const Filerobot = window.Filerobot;
const demoContainer = "scaleflex-tests-v5a";
const demoSecurityTemplateId = "......";

const filerobot = Filerobot.Core({
  securityTemplateId: demoSecurityTemplateId,
  container: demoContainer,
  dev: false, // optional, default: false
});

const Explorer = Filerobot.Explorer;
const XHRUpload = Filerobot.XHRUpload;

filerobot
  .use(Explorer, { target: "#filerobot-widget", inline: true })
  .use(XHRUpload);

// events
filerobot.on("upload", () => {
  // trigger when upload is clicked inside explorer
});
filerobot.on("upload-started", () => {
  // trigger when upload starts
});
filerobot.on("upload-progress", () => {
  // trigger when upload is progressing
});
filerobot.on("upload-success", () => {
  // trigger when upload is completed
});
filerobot.on("upload-error", () => {
  // trigger when upload has an error
});

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.