Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}%`)
})
Upload.addListener('completed', uploadId, (data) => {
console.log('Completed!')
})
}).catch(function(err) {
this.setState({ uploadId: null, progress: null })
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}%`)
})
Upload.addListener('completed', uploadId, (data) => {
console.log('Completed!')
})
}).catch(function(err) {
this.setState({ uploadId: null, progress: null })
setup() {
Upload.addListener('progress', undefined, this.uploadProgress.bind(this))
Upload.addListener('completed', undefined, this.uploadComplete.bind(this))
Upload.addListener('cancelled', undefined, this.uploadCancelled.bind(this))
Upload.addListener('error', undefined, this.uploadError.bind(this))
}
setup() {
Upload.addListener('progress', undefined, this.uploadProgress.bind(this))
Upload.addListener('completed', undefined, this.uploadComplete.bind(this))
Upload.addListener('cancelled', undefined, this.uploadCancelled.bind(this))
Upload.addListener('error', undefined, this.uploadError.bind(this))
}
setup() {
Upload.addListener('progress', undefined, this.uploadProgress.bind(this))
Upload.addListener('completed', undefined, this.uploadComplete.bind(this))
Upload.addListener('cancelled', undefined, this.uploadCancelled.bind(this))
Upload.addListener('error', undefined, this.uploadError.bind(this))
}
setup () {
Upload.addListener('progress', null, this.uploadProgress.bind(this))
Upload.addListener('completed', null, this.uploadComplete.bind(this))
Upload.addListener('cancelled', null, this.uploadCancelled.bind(this))
Upload.addListener('error', null, this.uploadError.bind(this))
}
setup () {
Upload.addListener('progress', null, this.uploadProgress.bind(this))
Upload.addListener('completed', null, this.uploadComplete.bind(this))
Upload.addListener('cancelled', null, this.uploadCancelled.bind(this))
Upload.addListener('error', null, this.uploadError.bind(this))
}
'Cookie': `PHPSESSID=${session}; CSRF_TOKEN=${token}`,
'X-CSRF-Token': token,
'Content-Type': 'application/octet-stream',
}
const uploadId = await Upload.startUpload({
url,
method: 'PUT',
type: 'raw',
path,
headers,
notification: {
enabled: true
}
})
Upload.addListener('progress', uploadId, data => store.dispatch({type: BASKET_UPLOAD_PROGRESS, payload: data.progress}))
Upload.addListener('error', uploadId, () => store.dispatch({type: REQUEST_ERROR}))
Upload.addListener('cancelled', uploadId, () => store.dispatch({type: REQUEST_ERROR}))
Upload.addListener('completed', uploadId, () => resolve())
})