You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-24 23:26:50 +02:00
@ -1,6 +1,7 @@
|
||||
const moment = require('moment');
|
||||
const { dirname, basename } = require('./path-utils');
|
||||
const shim = require('./shim').default;
|
||||
const Buffer = require('buffer').Buffer;
|
||||
|
||||
class FileApiDriverOneDrive {
|
||||
constructor(api) {
|
||||
@ -133,17 +134,19 @@ class FileApiDriverOneDrive {
|
||||
if (!options) options = {};
|
||||
|
||||
let response = null;
|
||||
// We need to check the file size as files > 4 MBs are uploaded in a different way than files < 4 MB (see https://docs.microsoft.com/de-de/onedrive/developer/rest-api/concepts/upload?view=odsp-graph-online)
|
||||
let byteSize = null;
|
||||
|
||||
if (options.source == 'file') {
|
||||
// We need to check the file size as files > 4 MBs are uploaded in a different way than files < 4 MB (see https://docs.microsoft.com/de-de/onedrive/developer/rest-api/concepts/upload?view=odsp-graph-online)
|
||||
const fileSize = (await shim.fsDriver().stat(options.path)).size;
|
||||
path = fileSize < 4 * 1024 * 1024 ? `${this.makePath_(path)}:/content` : `${this.makePath_(path)}:/createUploadSession`;
|
||||
response = await this.api_.exec('PUT', path, null, null, options);
|
||||
byteSize = (await shim.fsDriver().stat(options.path)).size;
|
||||
} else {
|
||||
options.headers = { 'Content-Type': 'text/plain' };
|
||||
response = await this.api_.exec('PUT', `${this.makePath_(path)}:/content`, null, content, options);
|
||||
byteSize = Buffer.byteLength(content);
|
||||
}
|
||||
|
||||
path = byteSize < 4 * 1024 * 1024 ? `${this.makePath_(path)}:/content` : `${this.makePath_(path)}:/createUploadSession`;
|
||||
response = await this.api_.exec('PUT', path, null, content, options);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user