How to use react-native-background-upload - 10 common examples

To help you get started, we’ve selected a few react-native-background-upload examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Vydia / ReactNativeBackgroundUploadExample / js / components / Upload.js View on Github external
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}%`)
        })
        Upload.addListener('completed', uploadId, (data) => {
          console.log('Completed!')
        })
      }).catch(function(err) {
        this.setState({ uploadId: null, progress: null })
        console.log('Upload error!', err)
      })
github Vydia / ReactNativeBackgroundUploadExample / js / components / Upload.js View on Github external
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}%`)
github Vydia / ReactNativeBackgroundUploadExample / js / components / Upload.js View on Github external
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 })
github Vydia / ReactNativeBackgroundUploadExample / js / components / Upload.js View on Github external
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 })
github Vydia / ReactNativeBackgroundUploadExample / js / components / Upload.js View on Github external
cancelUpload = () => {
    if (!this.state.uploadid) {
      console.log('Nothing to cancel!')
      return
    }

    Upload.cancelUpload(this.state.uploadId).then((props) => {
      console.log(`Upload ${this.state.uploadId} canceled`)
      this.setState({ uploadId: null, progress: null })
    })
  }
github textileio / photos / App / Services / EventHandlers / UploadEventHandler.ts View on Github external
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))
  }
github textileio / photos / App / Services / EventHandlers / UploadEventHandler.ts View on Github external
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))
  }
github textileio / photos / App / Services / EventHandlers / UploadEventHandler.ts View on Github external
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))
  }
github textileio / photos / App / Services / EventHandlers / UploadEventHandler.ts View on Github external
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))
  }
github textileio / photos / App / Services / EventHandlers / UploadEventHandler.ts View on Github external
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))
  }

react-native-background-upload

Cross platform http post file uploader with android and iOS background support

MIT
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis