@useupup/vanilla
v3.3.5
Published
Framework-free DOM file uploader (lit-html) with cloud-drive sources, resumable uploads, theming, and ICU i18n.
Readme
@useupup/vanilla
Framework-free file uploader (built on lit-html) with cloud-drive sources (Google Drive, OneDrive, Dropbox, Box), resumable uploads, theming, and ICU i18n. A native port of the canonical upup React UI, DOM-identical to it — no framework required. Mount it into any DOM element.
Install
npm i @useupup/vanillaUsage (Client Mode)
Client Mode uploads directly from the browser to your storage; your server only
issues short-lived upload credentials at uploadEndpoint.
import { createUploader } from '@useupup/vanilla'
import '@useupup/vanilla/styles'
const uploader = createUploader('#uploader', {
provider: 'aws',
uploadEndpoint: '/api/upload-token',
onFileUploadComplete: (file, key) =>
console.log('Uploaded', file.name, 'to', key),
})createUploader(target, options) accepts a CSS selector string or an
HTMLElement. uploadEndpoint is your own route returning a presigned upload
URL — see the quickstart for a ready-made handler.
Custom element
A <upup-uploader> custom element is also published. Importing
@useupup/vanilla/element registers it, after which you can use it declaratively in
HTML:
import '@useupup/vanilla/element'Server Mode
For credential isolation and server-proxied cloud drives, add
@useupup/server and set the mode:
createUploader('#uploader', {
mode: 'server',
serverUrl: '/api/upup',
provider: 'aws',
})Also exported
FileSource, StorageProvider, and UploadStatus.
Links
License
MIT
