Uploading files through websocket to binary.com platform
npm install @binary-com/binary-document-uploader
First increase the version in package.json
according to major/minor/patch. Ideally this will be done in the same PR as your changes. After that, you can run:
npm run build
npm publish
Yarn automatically increases the version for you, so you only need to run:
yarn publish
The resulting DocumentUploader.js
should be committed and uploaded to this repository.
import DocumentUploader from 'binary-document-uploader';
const uploader = new DocumentUploader(config);
const DocumentUploader = require('binary-document-uploader');
const uploader = new DocumentUploader(config);
<script src="./documentUploader.js"></script>
<script>
const uploader = new DocumentUploader(config);
uploader(file);
</script>
import DocumentUploader from 'binary-document-uploader';
const uploader = new DocumentUploader(config);
uploader.upload(file)
.then(result => console.log(`Status: ${result.status}`))
.catch(error => console.log(error));
File information and payload to send
Filename
Array buffer containing the file to upload
Document type
Document id
Document format
Expiration date
Boolean value that indicates whether this document is lifetime valid (only applies to POI document types, cancels out the expiration_date given if any)
Default: 16384
(16 KB)
A ready websocket connection
Default: false