1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

All: Added backend for Dropbox support

This commit is contained in:
Laurent Cozic
2018-03-24 19:35:10 +00:00
parent 74b83eb71e
commit 0f4324c2f8
11 changed files with 441 additions and 32 deletions

View File

@ -111,10 +111,9 @@ function shimInit() {
const urlParse = require('url').parse;
url = urlParse(url.trim());
const method = options.method ? options.method : 'GET';
const http = url.protocol.toLowerCase() == 'http:' ? require('follow-redirects').http : require('follow-redirects').https;
const headers = options.headers ? options.headers : {};
const method = options.method ? options.method : 'GET';
if (method != 'GET') throw new Error('Only GET is supported');
const filePath = options.path;
function makeResponse(response) {
@ -143,7 +142,7 @@ function shimInit() {
// Note: relative paths aren't supported
const file = fs.createWriteStream(filePath);
const request = http.get(requestOptions, function(response) {
const request = http.request(requestOptions, function(response) {
response.pipe(file);
file.on('finish', function() {
@ -157,6 +156,8 @@ function shimInit() {
fs.unlink(filePath);
reject(error);
});
request.end();
} catch(error) {
fs.unlink(filePath);
reject(error);
@ -180,6 +181,8 @@ function shimInit() {
return Buffer.byteLength(string, 'utf-8');
}
shim.Buffer = Buffer;
}
module.exports = { shimInit };