mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-29 21:21:15 +02:00
All: Added uploadBlob method to Node apps
This commit is contained in:
parent
3f4f154949
commit
2959fa1080
ReactNativeClient/lib
@ -156,6 +156,16 @@ function shimInit() {
|
|||||||
|
|
||||||
return shim.fetchWithRetry(doFetchOperation, options);
|
return shim.fetchWithRetry(doFetchOperation, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shim.uploadBlob = async function(url, options) {
|
||||||
|
if (!options || !options.path) throw new Error('uploadBlob: source file path is missing');
|
||||||
|
const content = await fs.readFile(options.path);
|
||||||
|
options = Object.assign({}, options, {
|
||||||
|
body: content,
|
||||||
|
});
|
||||||
|
return shim.fetch(url, options);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { shimInit };
|
module.exports = { shimInit };
|
@ -46,10 +46,7 @@ function shimInit() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await shim.fetchWithRetry(doFetchBlob, options);
|
const response = await shim.fetchWithRetry(doFetchBlob, options);
|
||||||
// let response = await RNFetchBlob.config({
|
|
||||||
// path: localFilePath
|
|
||||||
// }).fetch(method, url, headers);
|
|
||||||
|
|
||||||
// Returns an object that's roughtly compatible with a standard Response object
|
// Returns an object that's roughtly compatible with a standard Response object
|
||||||
let output = {
|
let output = {
|
||||||
ok: response.respInfo.status < 400,
|
ok: response.respInfo.status < 400,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user