https://github.com/fiverr/uploader_package
https://github.com/fiverr/uploader_package
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fiverr/uploader_package
- Owner: fiverr
- Created: 2017-04-12T07:46:40.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-21T22:59:17.000Z (about 2 years ago)
- Last Synced: 2025-01-08T21:36:14.483Z (5 months ago)
- Language: JavaScript
- Size: 46.9 KB
- Stars: 1
- Watchers: 78
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Code of conduct: CODE_OF_CONDUCT.md
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
```