@superyachttimes/lib-uploader
v1.0.14
Published
Uploader library for the SuperYacht Times tech stack
Downloads
225
Readme
SYT Uploader
This small library allows SYT & YachtEye developers to upload (large) files directly to S3 in an very manner.
Usage
// set to true to enable debug logs
const enableDebugLogs = false
const onProgress = (progress) => {
// This is currently not yet used
console.log('Progress: ' + progress)
}
const onUploaded = ({ id, file, result }) => {
// the file was uploaded successfully
}
const uploader = new Uploader('https://api0.superyachtapi.com', 'MY_API_KEY', onProgress, onUploaded, enableDebugLogs)
/*
* @Param {File} file
* @Param {string} owner - e.g. current user ID or yacht ID
* @Param {string} service - e.g. "yachteye" or "sytiq"
*
* @Returns upload a file on behalf of service & owner
*/
await uploader.upload(file, owner, service)
/*
* @Param {string} owner - e.g. current user ID or yacht ID
* @Param {string} service - e.g. "yachteye" or "sytiq" (optional)
*
* @Returns a list of files uploaded by owner
*/
await uploader.getFiles(owner, [service])
NB The uploader will throw an error if anything fails along the way.