How to use the rn-fetch-blob.fetch function in rn-fetch-blob

To help you get started, we’ve selected a few rn-fetch-blob 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 blefebvre / react-native-sqlite-demo / src / sync / dropbox / DropboxDatabaseSync.ts View on Github external
private uploadDBToDropbox(
    localFilePath: string,
    dropboxFilePath: string,
    dropboxAccessToken: string
  ): Promise {
    console.log(
      `[Dropbox backup] UPLOADING local file [${localFilePath}] to remote file [${dropboxFilePath}]!`
    );
    return RNFetchBlob.fetch(
      "POST",
      DROPBOX.UPLOAD_URL,
      {
        Authorization: `Bearer ${dropboxAccessToken}`,
        "Content-Type": "application/octet-stream",
        "Dropbox-API-Arg": JSON.stringify({
          path: dropboxFilePath,
          mode: "overwrite"
        })
      },
      RNFetchBlob.wrap(localFilePath)
    ).then((fetchBlobResponse: any) => {
      console.log("[Dropbox backup] UPLOAD response!", fetchBlobResponse);
      // Ensure we have `data` and a 200 response
      if (
        fetchBlobResponse.data &&
github BrightID / BrightID / BrightID / src / components / OnboardingScreens / actions.js View on Github external
export const fakeUserAvatar = (): Promise => {
  // save each connection with their id as the async storage key
  return RNFetchBlob.fetch('GET', 'https://loremflickr.com/180/180/all', {})
    .then((res) => {
      if (res.info().status === 200) {
        let b64 = res.base64();
        return b64;
      } else {
        return 'https://loremflickr.com/180/180/all';
      }
    })
    .catch((err) => console.log(err));
};
github BrightID / BrightID / BrightID / src / actions / fakeContact.js View on Github external
const signedMessage = uInt8ArrayToB64(
    nacl.sign.detached(strToUint8Array(message), secretKey),
  );

  const userData = {
    publicKey: b64PubKey,
    id,
    timestamp,
    secretKey,
    signedMessage,
    name,
    score,
    photo: 'https://loremflickr.com/180/180/all',
  };

  RNFetchBlob.fetch('GET', 'https://loremflickr.com/180/180/all', {})
    .then((res) => {
      if (res.info().status === 200) {
        userData.photo = `data:image/jpeg;base64,${String(res.base64())}`;
        dispatch(setConnectUserData(userData));
        navigation.navigate('PreviewConnection');
      } else {
        Alert.alert('Error', 'Unable to fetch image');
      }
    })
    .catch((err) => {
      console.log(err);
    });
};
github uport-project / uport-mobile / lib / utilities / ipfs.js View on Github external
return new Promise((resolve, reject) => {
    RNFetchBlob.fetch('GET', `${ipfsUrl}/ipfs/${ipfsHash}`).then(resolve).catch(reject)
  })
}
github uport-project / uport-mobile / lib / utilities / ipfs.js View on Github external
return new Promise((resolve, reject) => {
    RNFetchBlob.fetch('GET', `${ipfsUrl}/ipfs/${ipfsHash}`).then((response) => resolve(response.text())).catch(reject)
  })
}
github uport-project / uport-mobile / lib / utilities / ipfs.js View on Github external
return new Promise((resolve, reject) => {
    RNFetchBlob.fetch('POST', addUrl, {
      'Content-Type': 'multipart/form-data'
    }, [ blob ]).then((response) => {
      resolve(response.json()['Hash'])
    }).catch((error) => {
      reject(error)
    })
  })
}