fix binary file
This commit is contained in:
parent
2371ee64d7
commit
369b39e848
8
main.ts
8
main.ts
@ -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}`);
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user