Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
startUpload = (opts) => {
Upload.getFileInfo(opts.path).then((metadata) => {
const options = Object.assign({
method: 'POST',
headers: {
'content-type': metadata.mimeType // server requires a content-type header
}
}, opts)
Upload.startUpload(options).then((uploadId) => {
console.log(`Upload started with options: ${JSON.stringify(options)}`)
this.setState({ uploadId, progress: 0 })
Upload.addListener('progress', uploadId, (data) => {
this.handleProgress(+data.progress)
console.log(`Progress: ${data.progress}%`)
})
Upload.addListener('error', uploadId, (data) => {
console.log(`Error: ${data.error}%`)