mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
When the mobile application tries to synchronize a note with attached resource files, e.g. from the notebook "Welcome! (Mobile)", readFile() is called to return a Buffer although that isn't implemented in FsDriverRN.readFile(). This is changing the code to return base64 encoded content from react-native and turn it into a Buffer before the S3 putObject() API call is used to create the remote object. Tested with AVD Android 10.0 target. Signed-off-by: Jan Blunck <jblunck@users.noreply.github.com>
This commit is contained in:
parent
f001d197a8
commit
f965708ad3
@ -2,6 +2,7 @@ const { basicDelta } = require('./file-api');
|
||||
const { basename } = require('./path-utils');
|
||||
const shim = require('./shim').default;
|
||||
const JoplinError = require('./JoplinError');
|
||||
const { Buffer } = require('buffer');
|
||||
|
||||
const S3_MAX_DELETES = 1000;
|
||||
|
||||
@ -83,12 +84,14 @@ class FileApiDriverAmazonS3 {
|
||||
|
||||
async s3UploadFileFrom(path, key) {
|
||||
if (!shim.fsDriver().exists(path)) throw new Error('s3UploadFileFrom: file does not exist');
|
||||
const body = await shim.fsDriver().readFile(path, 'Buffer');
|
||||
const body = await shim.fsDriver().readFile(path, 'base64');
|
||||
const fileStat = await shim.fsDriver().stat(path);
|
||||
return new Promise((resolve, reject) => {
|
||||
this.api().upload({
|
||||
this.api().putObject({
|
||||
Bucket: this.s3_bucket_,
|
||||
Key: key,
|
||||
Body: body,
|
||||
Body: Buffer.from(body, 'base64'),
|
||||
ContentLength: `${fileStat.size}`,
|
||||
}, (err, response) => {
|
||||
if (err) reject(err);
|
||||
else resolve(response);
|
||||
|
Loading…
Reference in New Issue
Block a user