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 path from "path";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
import { Buffer } from "buffer";
|
||||||
|
import * as mime from 'mime-types';
|
||||||
import {
|
import {
|
||||||
App,
|
App,
|
||||||
Modal,
|
Modal,
|
||||||
@ -86,7 +88,7 @@ export default class SaveRemotePlugin extends Plugin {
|
|||||||
} else {
|
} else {
|
||||||
// file
|
// file
|
||||||
console.log(`file ${fileOrFolder.path}`);
|
console.log(`file ${fileOrFolder.path}`);
|
||||||
const strContent = await this.app.vault.adapter.read(
|
const arrContent = await this.app.vault.adapter.readBinary(
|
||||||
fileOrFolder.path
|
fileOrFolder.path
|
||||||
);
|
);
|
||||||
new Notice(`file ${fileOrFolder.path}`);
|
new Notice(`file ${fileOrFolder.path}`);
|
||||||
@ -94,11 +96,13 @@ export default class SaveRemotePlugin extends Plugin {
|
|||||||
new PutObjectCommand({
|
new PutObjectCommand({
|
||||||
Bucket: this.settings.s3BucketName,
|
Bucket: this.settings.s3BucketName,
|
||||||
Key: `${fileOrFolder.path}`,
|
Key: `${fileOrFolder.path}`,
|
||||||
Body: strContent,
|
Body: Buffer.from(arrContent),
|
||||||
|
ContentType: mime.contentType(`${fileOrFolder.path}`) || undefined
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
new Notice('All upload finished!')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Error", err);
|
console.log("Error", err);
|
||||||
new Notice(`${err}`);
|
new Notice(`${err}`);
|
||||||
|
|||||||
@ -38,11 +38,13 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.37.0",
|
"@aws-sdk/client-s3": "^3.37.0",
|
||||||
|
"@types/mime-types": "^2.1.1",
|
||||||
"codemirror": "^5.63.1",
|
"codemirror": "^5.63.1",
|
||||||
|
"mime-types": "^2.1.33",
|
||||||
|
"obsidian": "^0.12.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"webdav": "^4.7.0",
|
"webdav": "^4.7.0",
|
||||||
"webdav-fs": "^4.0.0",
|
"webdav-fs": "^4.0.0"
|
||||||
"obsidian": "^0.12.0"
|
|
||||||
},
|
},
|
||||||
"@parcel/transformer-js": {
|
"@parcel/transformer-js": {
|
||||||
"inlineFS": false,
|
"inlineFS": false,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user