Skip to content

Commit 981fc1f

Browse files
committed
enhance R2Uploader to set Content-Type during uploads
Signed-off-by: Addo.Zhang <[email protected]>
1 parent 06f2072 commit 981fc1f

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"authorUrl": "https://atbug.com",
77
"isDesktopOnly": true,
88
"minAppVersion": "0.11.0",
9-
"version": "1.0.0"
9+
"version": "1.0.1"
1010
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-image-upload-toolkit",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "",
55
"author": "addozhang",
66
"main": "main.js",

src/uploader/r2/r2Uploader.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ export default class R2Uploader implements ImageUploader {
3131
Bucket: this.bucket,
3232
Key: path,
3333
Body: uint8Array,
34+
ContentType: `image/${image.name.split('.').pop()}`,
3435
};
3536
return new Promise((resolve, reject) => {
3637
this.r2.upload(params, (err, data) => {
3738
if (err) {
3839
reject(err);
3940
} else {
40-
resolve(UploaderUtils.customizeDomainName(data.Key, this.customDomainName));
41+
const dst = data.Location.split(`/${this.bucket}/`).pop();
42+
resolve(UploaderUtils.customizeDomainName(dst, this.customDomainName));
4143
}
4244
});
4345
});

0 commit comments

Comments
 (0)