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 CHANGED
@@ -59,6 +59,13 @@ export declare const shareServices: {
59
59
  default: string;
60
60
  required: boolean;
61
61
  };
62
+ addTimestamp: {
63
+ title: string;
64
+ description: string;
65
+ type: string;
66
+ default: boolean;
67
+ required: boolean;
68
+ };
62
69
  };
63
70
  }[];
64
71
  export {};
package/dist/index.js CHANGED
@@ -36,15 +36,17 @@ const action = async (context) => {
36
36
  context.cancel();
37
37
  return;
38
38
  }
39
- if (!publicUrl.startsWith("https://")) {
40
- context.notify("Public URL must start with https://");
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 filename = path_1.default.basename(filePath);
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 the Cloudflare dashboard under R2 > Manage R2 API Tokens.",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kap-r2",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Share on Cloudflare R2",
5
5
  "license": "MIT",
6
6
  "repository": "tristanremy/kap-r2",
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 Dashboard](https://dash.cloudflare.com) under R2 → Manage R2 API Tokens.
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