fix binary file

This commit is contained in:
fyears 2021-10-19 00:38:20 +08:00
parent 2371ee64d7
commit 369b39e848
2 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,7 @@
import * as path from "path";
import * as fs from "fs";
import { Buffer } from "buffer";
import * as mime from 'mime-types';
import {
App,
Modal,
@ -86,7 +88,7 @@ export default class SaveRemotePlugin extends Plugin {
} else {
// file
console.log(`file ${fileOrFolder.path}`);
const strContent = await this.app.vault.adapter.read(
const arrContent = await this.app.vault.adapter.readBinary(
fileOrFolder.path
);
new Notice(`file ${fileOrFolder.path}`);
@ -94,11 +96,13 @@ export default class SaveRemotePlugin extends Plugin {
new PutObjectCommand({
Bucket: this.settings.s3BucketName,
Key: `${fileOrFolder.path}`,
Body: strContent,
Body: Buffer.from(arrContent),
ContentType: mime.contentType(`${fileOrFolder.path}`) || undefined
})
);
}
}
new Notice('All upload finished!')
} catch (err) {
console.log("Error", err);
new Notice(`${err}`);

View File

@ -38,11 +38,13 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.37.0",
"@types/mime-types": "^2.1.1",
"codemirror": "^5.63.1",
"mime-types": "^2.1.33",
"obsidian": "^0.12.0",
"rimraf": "^3.0.2",
"webdav": "^4.7.0",
"webdav-fs": "^4.0.0",
"obsidian": "^0.12.0"
"webdav-fs": "^4.0.0"
},
"@parcel/transformer-js": {
"inlineFS": false,