kap-r2 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -0
- package/dist/index.js +13 -4
- package/package.json +1 -1
- package/readme.md +2 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -36,15 +36,17 @@ const action = async (context) => {
|
|
|
36
36
|
context.cancel();
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
if (
|
|
40
|
-
context.notify("Public URL must
|
|
39
|
+
if (!/^https:\/\/.+/.test(publicUrl)) {
|
|
40
|
+
context.notify("Public URL must be a valid https:// URL");
|
|
41
41
|
context.cancel();
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
const filePath = await context.filePath();
|
|
45
45
|
const fileBuffer = await (0, promises_1.readFile)(filePath);
|
|
46
46
|
context.setProgress("Uploading to R2…", 0);
|
|
47
|
-
const
|
|
47
|
+
const addTimestamp = context.config.get("addTimestamp") === "true";
|
|
48
|
+
const originalFilename = path_1.default.basename(filePath);
|
|
49
|
+
const filename = addTimestamp ? `${Date.now()}-${originalFilename}` : originalFilename;
|
|
48
50
|
const key = directory ? path_1.default.posix.join(directory, filename) : filename;
|
|
49
51
|
const extension = path_1.default.extname(filename);
|
|
50
52
|
const contentType = contentTypes.get(extension) || "application/octet-stream";
|
|
@@ -100,7 +102,7 @@ const r2 = {
|
|
|
100
102
|
title: "Share to R2",
|
|
101
103
|
formats: ["gif", "mp4", "webm", "apng"],
|
|
102
104
|
action,
|
|
103
|
-
configDescription: "Configure your Cloudflare R2 credentials. Get your API tokens from
|
|
105
|
+
configDescription: "Configure your Cloudflare R2 credentials. Get your API tokens from https://dash.cloudflare.com/?to=/:account/r2/api-tokens",
|
|
104
106
|
config: {
|
|
105
107
|
accountId: {
|
|
106
108
|
title: "Account ID",
|
|
@@ -138,6 +140,13 @@ const r2 = {
|
|
|
138
140
|
default: "",
|
|
139
141
|
required: true,
|
|
140
142
|
},
|
|
143
|
+
addTimestamp: {
|
|
144
|
+
title: "Add Timestamp to Filename",
|
|
145
|
+
description: "Prefix filenames with timestamp to avoid overwrites",
|
|
146
|
+
type: "boolean",
|
|
147
|
+
default: false,
|
|
148
|
+
required: false,
|
|
149
|
+
},
|
|
141
150
|
},
|
|
142
151
|
};
|
|
143
152
|
exports.shareServices = [r2];
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -22,8 +22,9 @@ In the `Kap` menu, go to `Preferences…`, select the `Plugins` pane, find this
|
|
|
22
22
|
| Bucket Name | Your R2 bucket name |
|
|
23
23
|
| Directory | Optional subfolder path |
|
|
24
24
|
| Public URL | Your bucket's public URL (e.g., `https://pub-xxx.r2.dev`) |
|
|
25
|
+
| Add Timestamp to Filename | Prefix filenames with timestamp to avoid overwrites |
|
|
25
26
|
|
|
26
|
-
Get your API credentials from the [Cloudflare
|
|
27
|
+
Get your API credentials from the [Cloudflare R2 API Tokens page](https://dash.cloudflare.com/?to=/:account/r2/api-tokens).
|
|
27
28
|
|
|
28
29
|
## License
|
|
29
30
|
|