An open API service indexing awesome lists of open source software.

https://github.com/fiverr/uploader_package


https://github.com/fiverr/uploader_package

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# Fiverr Uploader Package
Uploader package for client side usage, handles interaction with the server, and manipulating the files uploaded through it (pretty file size calculation, extension extraction, max files counting...).

Usage:
```
import UploadController from '@fiverr-private/uploader';

const uploader = new UploadController({
url: `${location.protocol}//${location.host}/message_attachments`, // your attachments route
maxFiles: 10,
updateCb: this.updateAttachment, // callback for updating the state in your application
onLoad: this.onAttachmentLoad, // callback for marking a file as uploaded
headers: {
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
},
maxFilesText: 'Max. Files Reached' // text for marking max-files-exceeded
});

uploader.onAttach(files: FileList) // Add new files to the uploader.
uploader.onDetach(fileId: string) // Remove a file from the state.
```

And then, to get all attachments:
```
const attachments = uploader.attachmnts; // an object representing all the files uploaded
```