kap-r2 1.0.7 → 1.1.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.
Files changed (3) hide show
  1. package/dist/index.js +2 -21
  2. package/package.json +1 -1
  3. package/readme.md +86 -13
package/dist/index.js CHANGED
@@ -7,13 +7,7 @@ exports.shareServices = void 0;
7
7
  const promises_1 = require("fs/promises");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const https_1 = __importDefault(require("https"));
10
- const os_1 = __importDefault(require("os"));
11
10
  const aws4_1 = __importDefault(require("aws4"));
12
- const logFile = path_1.default.join(os_1.default.homedir(), "kap-r2-debug.log");
13
- const log = async (msg) => {
14
- const line = `[${new Date().toISOString()}] ${msg}\n`;
15
- await (0, promises_1.appendFile)(logFile, line).catch(() => { });
16
- };
17
11
  const contentTypes = new Map([
18
12
  [".gif", "image/gif"],
19
13
  [".mp4", "video/mp4"],
@@ -51,9 +45,6 @@ const action = async (context) => {
51
45
  const filePath = await context.filePath();
52
46
  const fileStats = await (0, promises_1.stat)(filePath);
53
47
  const fileBuffer = await (0, promises_1.readFile)(filePath);
54
- await log(`--- New upload ---`);
55
- await log(`File: ${filePath}, Size: ${fileStats.size}`);
56
- await log(`Account: ${accountId}, Bucket: ${bucket}`);
57
48
  context.setProgress("Uploading to R2…", 0);
58
49
  const filename = path_1.default.basename(filePath);
59
50
  const key = directory ? path_1.default.posix.join(directory, filename) : filename;
@@ -62,9 +53,6 @@ const action = async (context) => {
62
53
  const host = `${accountId}.r2.cloudflarestorage.com`;
63
54
  const encodedKey = key.split("/").map(encodeURIComponent).join("/");
64
55
  const fullPath = `/${bucket}/${encodedKey}`;
65
- await log(`Host: ${host}`);
66
- await log(`Path: ${fullPath}`);
67
- await log(`Content-Type: ${contentType}`);
68
56
  const request = aws4_1.default.sign({
69
57
  host,
70
58
  path: fullPath,
@@ -80,10 +68,8 @@ const action = async (context) => {
80
68
  accessKeyId,
81
69
  secretAccessKey,
82
70
  });
83
- await log(`Signed headers: ${JSON.stringify(request.headers)}`);
84
71
  try {
85
72
  await new Promise((resolve, reject) => {
86
- log(`Making HTTPS request...`);
87
73
  const req = https_1.default.request({
88
74
  hostname: host,
89
75
  path: fullPath,
@@ -92,10 +78,8 @@ const action = async (context) => {
92
78
  }, (res) => {
93
79
  const chunks = [];
94
80
  res.on("data", (chunk) => chunks.push(chunk));
95
- res.on("end", async () => {
81
+ res.on("end", () => {
96
82
  const body = Buffer.concat(chunks).toString();
97
- await log(`Response status: ${res.statusCode}`);
98
- await log(`Response body: ${body}`);
99
83
  if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
100
84
  resolve();
101
85
  }
@@ -104,10 +88,7 @@ const action = async (context) => {
104
88
  }
105
89
  });
106
90
  });
107
- req.on("error", (err) => {
108
- log(`Request error: ${err.message}`);
109
- reject(err);
110
- });
91
+ req.on("error", reject);
111
92
  context.setProgress("Uploading to R2…", 0.5);
112
93
  req.end(fileBuffer);
113
94
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kap-r2",
3
- "version": "1.0.7",
3
+ "version": "1.1.0",
4
4
  "description": "Share on Cloudflare R2",
5
5
  "license": "MIT",
6
6
  "repository": "tristanremy/kap-r2",
package/readme.md CHANGED
@@ -1,37 +1,110 @@
1
1
  # kap-r2
2
2
 
3
- > [Kap](https://github.com/wulkano/Kap) plugin - Share on Cloudflare R2
3
+ > [Kap](https://github.com/wulkano/Kap) plugin - Upload recordings to Cloudflare R2
4
+
5
+ Instantly share your Kap screen recordings via Cloudflare R2 storage. After recording, your file is uploaded and the public URL is automatically copied to your clipboard.
4
6
 
5
7
  ## Install
6
8
 
7
- In the `Kap` menu, go to `Preferences…`, select the `Plugins` pane, find this plugin, and click `Install`.
9
+ In the `Kap` menu, go to `Preferences…`, select the `Plugins` pane, search for `kap-r2`, and click `Install`.
8
10
 
9
11
  ## Configuration
10
12
 
13
+ After installing, click the gear icon next to the plugin to configure it.
14
+
11
15
  | Setting | Description |
12
16
  |---------|-------------|
13
- | **Account ID** | Your Cloudflare account ID |
17
+ | **Account ID** | Your Cloudflare account ID (32-character hex string) |
14
18
  | **Access Key ID** | R2 API token access key |
15
19
  | **Secret Access Key** | R2 API token secret |
16
20
  | **Bucket Name** | Name of your R2 bucket |
17
21
  | **Directory** | Optional subfolder path (e.g., `recordings/`) |
18
- | **Public URL** | Your bucket's public URL (R2.dev or custom domain) |
22
+ | **Public URL** | Your bucket's public URL (must start with `https://`) |
23
+
24
+ ## Setup Guide
25
+
26
+ ### Step 1: Find Your Account ID
27
+
28
+ 1. Log in to the [Cloudflare Dashboard](https://dash.cloudflare.com)
29
+ 2. Select your account
30
+ 3. Go to **R2** in the left sidebar
31
+ 4. Your **Account ID** is displayed in the right sidebar under "Account details"
32
+
33
+ ### Step 2: Create an R2 Bucket
34
+
35
+ 1. In the R2 section, click **Create bucket**
36
+ 2. Enter a bucket name (lowercase letters, numbers, and hyphens only)
37
+ 3. Click **Create bucket**
38
+
39
+ ### Step 3: Enable Public Access
40
+
41
+ You need to make your bucket publicly accessible. Choose one option:
19
42
 
20
- ### Getting R2 API Credentials
43
+ #### Option A: R2.dev Subdomain (Easiest)
21
44
 
22
- 1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com)
23
- 2. Navigate to **R2** > **Manage R2 API Tokens**
24
- 3. Click **Create API Token**
25
- 4. Grant **Object Read & Write** permissions
26
- 5. Save the **Access Key ID** and **Secret Access Key**
45
+ 1. Click on your bucket
46
+ 2. Go to **Settings** tab
47
+ 3. Under "Public access", find **R2.dev subdomain**
48
+ 4. Click **Allow Access**
49
+ 5. Copy the provided URL (e.g., `https://pub-abc123.r2.dev`)
27
50
 
28
- ### Setting Up Public Access
51
+ #### Option B: Custom Domain
29
52
 
30
- Enable the R2.dev subdomain in bucket settings or connect a custom domain.
53
+ 1. Click on your bucket
54
+ 2. Go to **Settings** tab
55
+ 3. Under "Public access", click **Connect Domain**
56
+ 4. Follow the instructions to add your custom domain
57
+ 5. Use your domain as the Public URL (e.g., `https://cdn.yourdomain.com`)
58
+
59
+ ### Step 4: Create API Credentials
60
+
61
+ 1. In the R2 section, click **Manage R2 API Tokens** (top right)
62
+ 2. Click **Create API token**
63
+ 3. Give it a name (e.g., "Kap Upload")
64
+ 4. Under "Permissions", select **Object Read & Write**
65
+ 5. Under "Specify bucket(s)", choose your bucket or select "Apply to all buckets"
66
+ 6. Click **Create API Token**
67
+ 7. **Important**: Copy both the **Access Key ID** and **Secret Access Key** immediately — the secret is only shown once!
68
+
69
+ ### Step 5: Configure the Plugin
70
+
71
+ 1. Open Kap → Preferences → Plugins
72
+ 2. Click the gear icon next to kap-r2
73
+ 3. Fill in all the fields:
74
+ - **Account ID**: The 32-character ID from Step 1
75
+ - **Access Key ID**: From Step 4
76
+ - **Secret Access Key**: From Step 4
77
+ - **Bucket Name**: The name you chose in Step 2
78
+ - **Directory**: Leave empty or enter a folder name (optional)
79
+ - **Public URL**: The URL from Step 3 (must start with `https://`)
31
80
 
32
81
  ## Usage
33
82
 
34
- After recording in Kap, select an export format, then click **Share to R2**.
83
+ 1. Record your screen with Kap
84
+ 2. Choose an export format (GIF, MP4, WebM, or APNG)
85
+ 3. Click **Share to R2**
86
+ 4. Wait for the upload to complete
87
+ 5. The public URL is automatically copied to your clipboard
88
+
89
+ ## Troubleshooting
90
+
91
+ ### "Export cancelled" immediately
92
+ - Make sure all required fields are configured in the plugin settings
93
+ - Check that your Account ID is exactly 32 characters (lowercase hex)
94
+ - Verify your Public URL starts with `https://`
95
+
96
+ ### Upload fails with authentication error
97
+ - Double-check your Access Key ID and Secret Access Key
98
+ - Make sure your API token has "Object Read & Write" permission
99
+ - Verify the token has access to the specified bucket
100
+
101
+ ### File not appearing in bucket
102
+ - Check the Cloudflare R2 dashboard to see if the file was uploaded
103
+ - Verify your bucket name is correct (case-sensitive)
104
+
105
+ ### URL doesn't work
106
+ - Make sure public access is enabled on your bucket
107
+ - Verify the Public URL matches your R2.dev subdomain or custom domain exactly
35
108
 
36
109
  ## License
37
110