Wondering what’s next for npm?Check out our public roadmap! »

sme-uploader
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

SME Uploader

SME Uploader logo

Build Status

SME Uploader is a sleek, modular JavaScript file uploader that integrates seamlessly with any application. It’s fast, easy to use and lets you worry about more important problems than building a file uploader.

Read the docs | Try SME Uploader

Example

Code used in the above example:

const SmeUploader = require('@sme-uploader/core')
const Dashboard = require('@sme-uploader/dashboard')
const Tus = require('@sme-uploader/tus')
 
const uploader = new SmeUploader({ autoProceed: false })
  .use(Dashboard, { trigger: '#select-files' })
  .use(Tus, { endpoint: 'https://master.tus.io/files/' }) // use your tus endpoint here
  .on('complete', (result) => {
    console.log('Upload result:', result)
  })

Try it online or Read the Docs for more details on how to use SME Uploader and its plugins.

Features

  • Lightweight and modular, plugin-based architecture, easy on dependencies.
  • Uses no frameworks (such as ExtJS or Angular).
  • On the back end, only a configurable binary executable listens on a port, and redirects the upload chunks to an AWS S3 bucket.
  • Large uploads survive network hiccups thanks to resumable file uploads via the open tus standard.
  • Sleek user interface.
  • A user can pause an upload (for example, if they are about to go offline), and resume later.
  • Works great with the file encoding and processing backend from Grafana, but also works great without.
  • Speaks multiple languages (i18n).
  • Built with accessibility in mind.

Installation

$ npm install @sme-uploader/core @sme-uploader/dashboard @sme-uploader/tus

We recommend installing from npm and then using a module bundler such as Parcel, Webpack or Browserify.

Alternatively, you can also use a pre-built bundle from CDN. In that case SmeUploader will attach itself to the global window.SmeUploader object.

⚠️ The bundle currently consists of most SME Uploader plugins, so this method is not recommended for production, as your users will have to download all plugins when you are likely using just a few.

<!-- 1. Add CSS to `<head>` -->
<link href="https://CDN/sme-uploader/v1.0.0/sme-uploader.min.css" rel="stylesheet">
 
<!-- 2. Add JS before the closing `</body>` -->
<script src="https://CDN/sme-uploader/v1.0.0/sme-uploader.min.js"></script>
 
<!-- 3. Initialize -->
<div class="SmeUploaderDragDrop"></div>
 
<script>
  let uploader = SmeUploader.Core()
  uploader.use(SmeUploader.DragDrop, { target: '.SmeUploaderDragDrop' })
  uploader.use(SmeUploader.Tus, { endpoint: '//master.tus.io/files/' })
</script> 

Documentation

  • SME Uploader — full list of options, methods and events
  • Plugins — list of SME Uploader plugins and their options
  • Companion — setting up and running a Companion instance, which adds support for Instagram, Dropbox, Google Drive and remote URLs

Plugins

List of plugins and their common options

UI Elements

  • Dashboard — universal UI with previews, progress bars, metadata editor and all the cool stuff. Required for most UI plugins like Webcam and Instagram
  • Progress Bar — minimal progress bar that fills itself when upload progresses
  • Status Bar — more detailed progress, pause/resume/cancel buttons, percentage, speed, uploaded/total sizes (included by default with Dashboard)
  • Informer — send notifications like “smile” before taking a selfie or “upload failed” when all is lost (also included by default with Dashboard)

Sources

  • Drag & Drop — plain and simple drag and drop area
  • File Input — even plainer “select files” button
  • Webcam — snap and record those selfies
  • Google Drive — import files from Google Drive
  • Dropbox — import files from Dropbox
  • Instagram — import images and videos from Instagram
  • Facebook — import images and videos from Facebook
  • OneDrive — import files from Microsoft OneDrive
  • Import From URL — import direct URLs from anywhere on the web

The ⓒ mark means that @sme-uploader/companion, a server-side component, is needed for a plugin to work.

Destinations

  • Tus — resumable uploads via the open tus standard
  • XHR Upload — regular uploads for any backend out there (like Apache, Nginx)
  • AWS S3 — plain upload to AWS S3 or compatible services
  • AWS S3 Multipart — S3-style "Multipart" upload to AWS or compatible services

File Processing

  • Robodog — user friendly abstraction to do file processing with Transloadit
  • Transloadit — support for Transloadit’s robust file uploading and encoding backend

Miscellaneous

  • Golden Retriever — restores files after a browser crash, like it’s nothing
  • Thumbnail Generator — generates image previews (included by default with Dashboard)
  • Form — collects metadata from <form> right before an SME Uploader upload, then optionally appends results back to the form
  • Redux — for your emerging time traveling needs

Browser Support

Sauce Test Status

We aim to support recent versions of Chrome, Firefox, Safari, Opera and Edge.

FAQ

Why not just use <input type="file">?

Having no JavaScript beats having a lot of it, so that’s a fair question! We found that in cases, the file input leaves some to be desired:

  • We received complaints about broken uploads and found that resumable uploads are important, especially for big files and to be inclusive towards people on poorer connections (we also launched tus.io to attack that problem). SME Uploader uploads can survive network outages and browser crashes or accidental navigate-aways.
  • SME Uploader supports editing meta information before uploading (and e.g. cropping is planned).
  • There’s the situation where people are using their mobile devices and want to upload on the go, but they have their picture on Instagram, files in Dropbox or just a plain file URL from anywhere on the open web. SME Uploader allows to pick files from those and push it to the destination without downloading it to your mobile device first.
  • Accurate upload progress reporting is an issue on many platforms.
  • Some file validation — size, type, number of files — can be done on the client with SME Uploader.
  • SME Uploader integrates webcam support, in case your users want to upload a picture/video/audio that does not exist yet.
  • A larger drag and drop surface can be pleasant to work with. Some people also like that you can control the styling, language, etc.
  • SME Uploader is aware of encoding backends. Often after an upload, the server needs to rotate, detect faces, optimize for iPad, or what have you. SME Uploader can track progress of this and report back to the user in different ways.
  • Sometimes you might want your uploads to happen while you continue to interact on the same single page.

Not all apps need all of these features. An <input type="file"> is fine in many situations. But these were a few things that our customers hit/asked about enough to spark us to develop SME Uploader.

Does SME Uploader support S3 uploads?

Yes, there is an S3 plugin, please check out the docs for more.

Do I need to install a special service/server for SME Uploader? Can I use it with Rails/Node/Go/PHP?

Yes, whatever you want on the backend will work with @sme-uploader/xhr-upload plugin, since it just does a POST or PUT request. Here’s a PHP backend example.

If you want resumability with the Tus plugin, use one of the tus server implementations

And you’ll need @sme-uploader/companion if you’d like your users to be able to pick files from Instagram, Google Drive, Dropbox or via direct URLs (with more services coming).

Contributors

mcarpent007 gord004 niko00001 lapc002
mcarpent007 gord004 niko00001 lapc002

License

The MIT License.

Install

npm i sme-uploader

DownloadsWeekly Downloads

3

Version

1.0.7

License

MIT

Unpacked Size

6.03 MB

Total Files

51

Last publish

Collaborators

  • avatar