Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 &&
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));
};
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);
});
};
return new Promise((resolve, reject) => {
RNFetchBlob.fetch('GET', `${ipfsUrl}/ipfs/${ipfsHash}`).then(resolve).catch(reject)
})
}
return new Promise((resolve, reject) => {
RNFetchBlob.fetch('GET', `${ipfsUrl}/ipfs/${ipfsHash}`).then((response) => resolve(response.text())).catch(reject)
})
}
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)
})
})
}