Vydia / react-native-background-upload

Upload files in your React Native app even while it's backgrounded. Supports Android and iOS, including camera roll assets.
MIT License
723 stars 330 forks source link

TypeError: null is not an object (evaluating 'NativeModule.startUpload') #217

Closed captainamiedi closed 3 years ago

captainamiedi commented 3 years ago

I am trying to upload images but i keep getting TypeError: null is not an object (evaluating 'NativeModule.startUpload') Here is what i have done

      Upload.startUpload({
        url: url,
        path: ' file:///data/user..........',
        method: 'PUT',
        maxRetries: 2, // set retry count (Android only). Default 2
        headers: {
          'Content-Type': 'application/json',
          Authorization:  token,
        },
        notification: {
          enabled: true
        },
        useUtf8Charset: true
      }).then((uploadId) => {
        console.log('upload started');
        Upload.addListener('progress', uploadId, (data) => {
          // Add to global state so that it can be used in other components
          console.log(`Progress: ${data.progress}%`);
        });
        Upload.addListener('error', uploadId, (data) => {
          // Add to global state so that it can be used in other components
          console.log(`Error: ${data.error}%`);
        });
        Upload.addListener('cancelled', uploadId, (data) => {
          // Add to global state so that it can be used in other components
          console.log('Cancelled!');
        });
        Upload.addListener('completed', uploadId, (data) => {
          // Add to global state so that it can be used in other components
          // data includes responseCode: number and responseBody: Object
          console.log('Completed!');
          resolve();
        });
      }).catch((err) => {
        console.log('Upload error!', err);
        reject();
      });

This is the error i am getting _TypeError: null is not an object (evaluating 'NativeModule.startUpload') startUpload@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:208432:24 callee2$ tryCatch@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:24960:23 invoke@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:25136:32 tryCatch@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:24960:23 invoke@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:25036:30 http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:25066:19 tryCallTwo@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26993:9 doResolve@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27157:25 Promise@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27016:14 callInvokeWithMethodAndArg@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:25065:33 enqueue@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:25070:157 async@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:25087:69 tryCallTwo@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26993:9 doResolve@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27157:25 Promise@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27016:14 uploadImage

reime005 commented 3 years ago

did you rebuild the app? module seems to be unlinked

AliRehman7141 commented 2 years ago

@reime005 I did rebuild but still got the same error. on ios @captainamiedi did you find a solution for this.?