[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79GPPXW9TWRETV63CC42B5G":3,"skill-same:01M79GPPXW9TWRETV63CC42B5G":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M79GPPXW9TWRETV63CC42B5G","cloud-storage-web",null,"Complete guide for CloudBase cloud storage using Web SDK (@cloudbase\u002Fjs-sdk) - upload, download, temporary URLs, file management, and best practices.","infometa\u002Fworkbuddyskills","infometa","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F109397516?v=4","01M79FS3XQK361MJFWQ2GFK95C","01M79FS3YPWKZYW9EPAAP2BFBJ",447,"MIT","https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills\u002Fblob\u002Fmain\u002Fconnectors\u002Fcloudbase\u002Fskills\u002Freferences\u002Fcloud-storage-web\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: cloud-storage-web\ndescription: Complete guide for CloudBase cloud storage using Web SDK (@cloudbase\u002Fjs-sdk) - upload, download, temporary URLs, file management, and best practices.\nversion: 2.36.2\nlicense: MIT\nalwaysApply: false\n---\n\n## Sibling skills (local only)\n\nSibling CloudBase skills ship beside this skill. Use local relative paths such as `..\u002Fauth-tool-cloudbase\u002FSKILL.md`.\n\nIf a referenced sibling skill file is missing from this environment, ask the user to install the full CloudBase plugin (or the missing skill). Do **not** HTTP-fetch remote skill or protocol markdown into the agent context.\n\n# Cloud Storage Web SDK\n\n## Activation Contract\n\n### Use this first when\n\n- A browser or Web app must upload, download, or manage CloudBase storage objects through `@cloudbase\u002Fjs-sdk`.\n- The request mentions `uploadFile`, `getTempFileURL`, `deleteFile`, or `downloadFile` in frontend code.\n\n### Read before writing code if\n\n- The task is browser-side storage work but you still need to separate it from Mini Program storage, backend storage management, or static hosting deployment.\n- The request may be blocked by security domains or frontend auth.\n\n### Then also read\n\n- Web login and identity -> `..\u002Fauth-web-cloudbase\u002FSKILL.md`\n- General Web app setup -> `..\u002Fweb-development\u002FSKILL.md`\n- Direct storage management through MCP tools -> `..\u002Fcloudbase-platform\u002FSKILL.md`\n\n### Do NOT use for\n\n- Mini Program file APIs.\n- Backend or agent-side direct storage management through MCP.\n- Static website hosting deployment via `manageHosting(action=\"upload\")`.\n- Database operations.\n\n### Common mistakes \u002F gotchas\n\n- Uploading from browser code without configuring security domains.\n- Using this skill for static hosting instead of storage objects.\n- Mixing browser SDK upload flows with server-side file-management tasks.\n- Assuming temporary download URLs are permanent links.\n- Ignoring `STORAGE_NOT_EXIST`; it means the target storage bucket\u002Fresource is not ready, not that the browser upload code should fabricate a URL.\n- On local Vite or dev-server tasks, forgetting to whitelist the exact current browser `host:port` before testing `app.uploadFile()`.\n- Treating CloudBase PG \u002F `pgstore` like the legacy NoSQL CloudBase storage. PG environments use a separate `pgstore` backend whose buckets are NOT auto-created from your old NoSQL bucket. If `pgstore` has no bucket, every upload returns `STORAGE_BUCKET_NOT_FOUND` and the SDK then issues `PUT https:\u002F\u002Fundefined\u002F` (visible in DevTools as `net::ERR_NAME_NOT_RESOLVED`). Treat bucket existence as a hard prerequisite, just like Supabase: in Supabase Storage every upload must target an already-created bucket; CloudBase PG follows the same model.\n\n### Minimal checklist\n\n- Confirm the caller is a browser\u002FWeb app.\n- Initialize the Web SDK once.\n- Confirm CloudBase storage exists in the current environment before testing upload. Use available MCP management\u002Fquery tools to inspect or create\u002Fselect the storage bucket when the environment has no default bucket. **In a PG \u002F pgstore environment, the legacy NoSQL bucket from `DescribeEnvs` does NOT count as a usable pgstore bucket; create one explicitly before any browser upload. The legacy NoSQL bucket itself is still fine for legacy `app.uploadFile()` flows that already target it — PG and NoSQL storage coexist; this skill applies to BOTH.**\n- Check security-domain\u002FCORS requirements.\n- Pick the right storage method before coding.\n\n### Local dev recipe\n\nWhen the app runs on a local browser origin and must upload files from the frontend:\n\n1. Use `queryEnv` with `action=\"domains\"` to inspect the current security-domain whitelist.\n2. Convert the browser origin into the CloudBase whitelist entry format:\n   - Browser origin `http:\u002F\u002F127.0.0.1:4173` -> whitelist entry `127.0.0.1:4173`\n   - Browser origin `http:\u002F\u002Flocalhost:5173` -> whitelist entry `localhost:5173`\n3. If the exact current host entry is missing, call `envDomainManagement` with `action=\"create\"` and add that host entry before relying on `app.uploadFile()`.\n4. If the runtime port may change between runs, do not assume any fixed default port list is sufficient. Re-check the actual browser origin you are really using for testing or final validation, then add that exact `host:port`.\n5. Tell the user that security-domain changes may take a few minutes to propagate; poll `queryEnv(action=\"domains\")` rather than blind-sleeping for a fixed long interval.\n6. Only after that should you implement and test browser-side `app.uploadFile()` flows.\n\nIf `app.uploadFile()` returns `STORAGE_NOT_EXIST`, stop editing frontend code and fix the environment-side storage resource first. Re-check the environment storage list, create or select an available bucket if the task allows it, then retry the same SDK upload flow.\n\nIf the task uses browser-side file upload, treat this as a prerequisite rather than an optional cleanup.\n\n### Bucket existence prerequisite (mandatory before any upload code)\n\nJust like Supabase Storage, CloudBase Storage requires the target bucket to exist before any client-side upload. This is true for both legacy CloudBase NoSQL storage (`STORAGE_NOT_EXIST`) and the newer PG \u002F `pgstore` backend (`STORAGE_BUCKET_NOT_FOUND`).\n\nMental model parity with Supabase:\n\n| Step | Supabase | CloudBase |\n| ---- | -------- | --------- |\n| Create bucket | `supabase.storage.createBucket('covers', { public: true })` (admin-side, with service role) | In PG mode, create a `storage.buckets` bucket through PG storage HTTP API \u002F CLI \u002F console \u002F SQL on `storage.buckets` when appropriate. The browser SDK cannot create one. |\n| Upload | `supabase.storage.from('covers').upload('a.png', file)` | **PG 模式**: `app.storage.from('covers').upload('a.png', file)` — `from(bucketName)` 指定 pgstore 存储桶。\u003Cbr>**非 PG 模式**: `app.storage.from().upload('covers\u002Fa.png', file)` — bucket 名作为路径第一段。|\n| Bucket missing error | `Bucket not found` | Browser sees `STORAGE_BUCKET_NOT_FOUND` (PG) or `STORAGE_NOT_EXIST` (NoSQL), then a follow-up `PUT https:\u002F\u002Fundefined\u002F` because the SDK still tries to PUT a missing `metadata.url`. |\n\nRequired pre-upload steps in any task that needs browser uploads:\n\n1. List existing buckets first. For PG \u002F pgstore, the legacy NoSQL bucket (the `6d63-…-1409864723` shape returned by `DescribeEnvs.Storages[]`) is NOT a valid pgstore bucket — do not assume it works.\n2. If no usable bucket exists for the upload target (e.g. `covers`), create one through the PG storage management surface BEFORE editing frontend upload code. Adding `covers` as a path prefix in code does not auto-create a bucket.\n3. After creating the bucket, the upload pattern depends on environment:\n   - **PG \u002F pgstore**: `app.storage.from('covers').upload('\u003Cfile>', file)` — bucket 名传入 `from()`\n   - **Non-PG (NoSQL)**: `app.storage.from().upload('covers\u002F\u003Cfile>', file)` — bucket 名作为路径第一段\n4. If you see `net::ERR_NAME_NOT_RESOLVED` going to `https:\u002F\u002Fundefined\u002F` in DevTools, that is the SDK reacting to a missing `metadata.url` field — almost always because the bucket does not exist or the SDK request was rejected upstream. Inspect the failed `POST ...\u002Fv1\u002Fstorages\u002Fget-objects-upload-info` response in DevTools first; the `code` field (e.g. `STORAGE_BUCKET_NOT_FOUND`, `STORAGE_CONTENT_LENGTH_REQUIRED`, `INVALID_PARAM`) tells you exactly what to fix.\n\nDo not silently swallow upload failures. If `uploadCoverImage()` rejects, the parent `createArticle()` MUST also reject — never proceed to `db.from(...).insert(...)` with a fabricated URL or a placeholder, and never let the UI show a success toast.\n\n### ⚠️ PG mode upload: use `app.storage.from('bucket')`, NOT `app.uploadFile()`\n\nIn PG \u002F pgstore environments, use `app.storage.from('covers').upload(key, file)` for uploads and `app.storage.from('covers').createSignedUrl(path, expiresIn)` for getting access URLs.\n\nDo NOT use the legacy NoSQL APIs in PG mode:\n- ❌ `app.uploadFile()` — 这是旧 NoSQL 的上传 API\n- ❌ `app.getTempFileURL()` — 这是旧 NoSQL 的获取 URL 方式\n- ❌ `app.storage.from().upload('covers\u002Ffile', file)` — 没有传 bucket 名\n\nUse instead:\n- ✅ `app.storage.from('covers').upload('file', file)` — PG 模式上传\n- ✅ `app.storage.from('covers').createSignedUrl('file', 3600)` — 获取签名 URL（返回 `fullSignedURL` 字段）\n\n**Return shapes differ between modes (v3 SDK) — copy the right column:**\n\n| call | 传统模式 (`from()` 无参, `cloud:\u002F\u002F` fileID) | PG 模式 (`from('bucket')`, bucket 内对象名) |\n|---|---|---|\n| `upload(path, file)` | `{ data: { id, path, fullPath } }`；`upsert` 默认 **true** | `{ data: { id, ... } }`；`upsert` 默认 **false** |\n| `createSignedUrl(path, expiresIn)` | `await` → `{ data: { signedUrl } }` | `await` → `{ data: { fullSignedURL } }` |\n| `getPublicUrl(path)` | `await` → `{ data: { publicUrl } }` | **同步调用（不 await）** → `{ data: { publicUrl } }` |\n\nSource: [webv3\u002Fclassic\u002Fstorage.md](https:\u002F\u002Fdocs.cloudbase.net\u002Fapi-reference\u002Fwebv3\u002Fclassic\u002Fstorage.md) · [webv3\u002Fstorage.md](https:\u002F\u002Fdocs.cloudbase.net\u002Fapi-reference\u002Fwebv3\u002Fstorage.md)（raw markdown）。\n\n### PG mode URL resolution: 公开桶直链 vs 签名 URL\n\n| Bucket 类型 | URL 策略 | 代码 |\n|---|---|---|\n| 公开桶（`storage.buckets.public = true`） | 直链，无需登录态，可直接进 `\u003Cimg src>` | `app.storage.from('covers').getPublicUrl('a.png')` → `{ data: { publicUrl } }` |\n| 私有桶 | 签名 URL，带过期时间 | `app.storage.from('covers').createSignedUrl('a.png', 3600)` |\n\n- 公开桶直链能否访问取决于 `storage.objects` 的 RLS SELECT 策略是否放行 anon —— 建桶 SQL 与策略模板见 `postgresql-development-cloudbase\u002Freferences\u002Fstorage-pg.md` \"Public-read bucket template\"。\n- 展示层做 `onerror` 兜底（直链被策略拦下时降级到签名 URL），不要硬依赖单一取址流程。\n- 业务表只存 bucket + key（或 SDK 解析出的最终 URL），不要在浏览器手工拼接 URL。\n\n### Post-bucket: storage RLS (mandatory in PG \u002F pgstore environments)\n\nIn **PG \u002F pgstore** environments, storage access control is enforced through **PostgreSQL Row Level Security (RLS) on `storage.buckets` \u002F `storage.objects`** — exactly like Supabase Storage. These tables are already granted to `anon`, `authenticated`, and `service_role`; RLS is the permission gate. Traditional storage permission labels (`READONLY` \u002F `PRIVATE` \u002F `CUSTOM`) and JSON storage safe rules do not apply. The default RLS policy is deny all, so even if the bucket exists, `app.storage.from('covers').upload()` from a browser will fail with `STORAGE_PERMISSION_DENIED` unless you configure policies.\n\nUse `managePgDatabase(action=\"execute\", confirm=true)` to run the following SQL after creating the bucket:\n\n```sql\nALTER TABLE storage.objects ENABLE ROW LEVEL SECURITY;\n\n-- Allow authenticated users to upload files\nCREATE POLICY \"authenticated_upload\" ON storage.objects\n  FOR INSERT TO authenticated\n  WITH CHECK (true);\n\n-- Allow authenticated users to read\u002Fdownload files\nCREATE POLICY \"authenticated_read\" ON storage.objects\n  FOR SELECT TO authenticated\n  USING (true);\n\n-- Optional: allow users to update\u002Fdelete their own files\nCREATE POLICY \"users_manage_own\" ON storage.objects\n  FOR UPDATE TO authenticated\n  USING (auth.uid() = owner_id)\n  WITH CHECK (auth.uid() = owner_id);\n```\n\nKey points:\n- `storage.objects` RLS is **separate** from CloudBase legacy NoSQL storage security rules (`managePermissions` \u002F `ModifyStorageSafeRule`). In PG mode, always configure storage RLS via PG SQL, not the legacy security rule API.\n- Without these policies, the browser receives `STORAGE_PERMISSION_DENIED` when calling `app.storage.from('covers').upload()` in PG mode.\n- Use `IF NOT EXISTS` in a `DO $$` block when re-applying to avoid \"policy already exists\" errors on re-run.\n\n## Overview\n\nUse this skill for **browser-side cloud storage operations** through the CloudBase Web SDK.\n\nTypical tasks:\n\n- upload files from a browser\n- generate temporary download URLs\n- delete files\n- trigger browser downloads\n\n## SDK initialization\n\nInit reference: [webv3\u002Finitialization.md](https:\u002F\u002Fdocs.cloudbase.net\u002Fapi-reference\u002Fwebv3\u002Finitialization.md)\n\n```javascript\nimport cloudbase from \"@cloudbase\u002Fjs-sdk\";\n\nconst app = cloudbase.init({\n  env: \"your-env-id\",\n  accessKey: import.meta.env.VITE_PUBLISHABLE_KEY, \u002F\u002F publishable key — auto-provisioned, see below\n});\n```\n\nInitialization rules:\n\n- **Publishable key auto-provisioning (do not ask the user):** browser-side storage requests are data-plane calls that require a publishable `accessKey`. Before writing client code, call `queryAppAuth(action=\"getPublishableKey\")`; if empty, call `manageAppAuth(action=\"ensurePublishableKey\")`; then write the key to `.env.local` as `VITE_PUBLISHABLE_KEY` (create the file if missing) and read it via `import.meta.env.VITE_PUBLISHABLE_KEY`. Never hardcode the key into source files. Only fall back to the console (`https:\u002F\u002Ftcb.cloud.tencent.com\u002Fdev?envId={env}#\u002Fenv\u002Fapikey`) if both MCP calls fail.\n- Use synchronous initialization with a shared app instance.\n- Do not re-initialize in every component.\n- If the operation depends on user identity, handle auth before storage operations.\n\n## Method routing\n\n- Upload from browser -> `app.uploadFile()`\n- Temporary preview\u002Fdownload URL -> `app.getTempFileURL()`\n- Delete existing files -> `app.deleteFile()`\n- Trigger browser download -> `app.downloadFile()`\n\n## Upload\n\n```javascript\nconst result = await app.uploadFile({\n  cloudPath: \"uploads\u002Favatar.jpg\",\n  filePath: selectedFile\n});\n```\n\n### Upload rules\n\n- `cloudPath` must include the filename.\n- Use `\u002F` to create folder structure.\n- **In a CloudBase PG \u002F pgstore environment**, the `from(bucketName)` argument is used as the bucket name (e.g. `from('covers')`), and `upload(key, file)` takes a key without bucket prefix. The bucket must already exist. Same model as Supabase Storage — never upload into a not-yet-created bucket.\n- Validate file type and size before upload.\n- Show upload progress for larger files when UX matters.\n- On local dev origins, confirm the exact frontend origin already exists in environment security domains before assuming the upload path is usable.\n- Match against the whitelist entry format returned by `queryEnv(action=\"domains\")`, which is typically `host:port` instead of a full `http:\u002F\u002F...` URL.\n- If the environment has no storage bucket or the SDK returns `STORAGE_NOT_EXIST` \u002F `STORAGE_BUCKET_NOT_FOUND`, use CloudBase management\u002FMCP storage tools to create or choose a bucket before retrying. Do not treat this as a successful optional upload.\n- After `app.uploadFile()` succeeds, do **not** fabricate a public-looking URL by concatenating `envId`, bucket domain, or `cloudPath`. Use the returned `fileID` with `app.getTempFileURL()` and store or display the SDK-resolved URL instead.\n\n### Progress example\n\n```javascript\nawait app.uploadFile({\n  cloudPath: \"uploads\u002Favatar.jpg\",\n  filePath: selectedFile,\n  onUploadProgress: ({ loaded, total }) => {\n    const percent = Math.round((loaded * 100) \u002F total);\n    console.log(percent);\n  }\n});\n```\n\n## Temporary URLs\n\n```javascript\nconst result = await app.getTempFileURL({\n  fileList: [\n    {\n      fileID: \"cloud:\u002F\u002Fenv-id\u002Fuploads\u002Favatar.jpg\",\n      maxAge: 3600\n    }\n  ]\n});\n```\n\nUse temp URLs when the browser needs to preview or download private files without exposing a permanent public link.\n\nTypical upload + preview flow:\n\n```javascript\nconst uploadResult = await app.uploadFile({\n  cloudPath: \"uploads\u002Favatar.jpg\",\n  filePath: selectedFile\n});\n\nconst tempUrlResult = await app.getTempFileURL({\n  fileList: [{ fileID: uploadResult.fileID, maxAge: 3600 }]\n});\n\nconst previewUrl = tempUrlResult.fileList?.[0]?.tempFileURL || tempUrlResult.fileList?.[0]?.download_url;\nif (!previewUrl) {\n  throw new Error(\"Failed to resolve temporary file URL after upload\");\n}\n```\n\n## Delete files\n\n```javascript\nawait app.deleteFile({\n  fileList: [\"cloud:\u002F\u002Fenv-id\u002Fuploads\u002Fold-avatar.jpg\"]\n});\n```\n\nAlways inspect per-file results before assuming deletion succeeded.\n\n## Download files\n\n```javascript\nawait app.downloadFile({\n  fileID: \"cloud:\u002F\u002Fenv-id\u002Fuploads\u002Freport.pdf\"\n});\n```\n\nUse this for browser-initiated downloads. For programmatic rendering or preview, prefer `getTempFileURL()`.\n\n## Security-domain reminder\n\nTo avoid CORS problems, add your frontend domain in CloudBase security domains. In MCP-enabled workflows, prefer checking and updating this through tools before coding browser uploads.\n\n```json\n{ \"tool\": \"queryEnv\", \"action\": \"domains\" }\n```\n\nUse the actual browser origin when deciding what to add. If the page is running on a custom domain or a local dev port, add that exact `host:port` value instead of guessing from a hard-coded list.\n\n```json\n{\n  \"tool\": \"envDomainManagement\",\n  \"action\": \"create\",\n  \"domains\": [\"\u003Cactual-browser-host>:\u003Cactual-browser-port>\"]\n}\n```\n\nMatch the real browser origin to the whitelist entry format returned by `queryEnv(action=\"domains\")`. For local Vite and preview servers, the port can vary between runs, so avoid assuming any fixed default port is sufficient.\n\nTypical examples:\n\n- `\u003Cyour-local-host>:\u003Cactual-port>`\n- `\u003Cyour-custom-domain>`\n\n## Best practices\n\n1. Use a clear folder structure such as `uploads\u002F`, `avatars\u002F`, `documents\u002F`.\n2. Validate file size and type in the browser before upload.\n3. Use temporary URLs with reasonable expiration windows.\n4. Clean up obsolete files instead of leaving orphaned storage objects.\n5. Route privileged batch-management tasks to backend or MCP flows instead of browser direct access.\n\n## Error handling\n\n```javascript\ntry {\n  const result = await app.uploadFile({\n    cloudPath: \"uploads\u002Ffile.jpg\",\n    filePath: selectedFile\n  });\n  console.log(result.fileID);\n} catch (error) {\n  console.error(\"Storage operation failed:\", error);\n}\n```\n","## Sibling skills (local only)\n\nSibling CloudBase skills ship beside this skill. Use local relative paths such as `..\u002Fauth-tool-cloudbase\u002FSKILL.md`.\n\nIf a referenced sibling skill file is missing from this environment, ask the user to install the full CloudBase plugin (or the missing skill). Do **not** HTTP-fetch remote skill or protocol markdown into the agent context.\n\n# Cloud Storage Web SDK\n\n## Activation Contract\n\n### Use this first when\n\n- A browser or Web app must upload, download, or manage CloudBase storage objects through `@cloudbase\u002Fjs-sdk`.\n- The request mentions `uploadFile`, `getTempFileURL`, `deleteFile`, or `downloadFile` in frontend code.\n\n### Read before writing code if\n\n- The task is browser-side storage work but you still need to separate it from Mini Program storage, backend storage management, or static hosting deployment.\n- The request may be blocked by security domains or frontend auth.\n\n### Then also read\n\n- Web login and identity -> `..\u002Fauth-web-cloudbase\u002FSKILL.md`\n- General Web app setup -> `..\u002Fweb-development\u002FSKILL.md`\n- Direct storage management through MCP tools -> `..\u002Fcloudbase-platform\u002FSKILL.md`\n\n### Do NOT use for\n\n- Mini Program file APIs.\n- Backend or agent-side direct storage management through MCP.\n- Static website hosting deployment via `manageHosting(action=\"upload\")`.\n- Database operations.\n\n### Common mistakes \u002F gotchas\n\n- Uploading from browser code without configuring security domains.\n- Using this skill for static hosting instead of storage objects.\n- Mixing browser SDK upload flows with server-side file-management tasks.\n- Assuming temporary download URLs are permanent links.\n- Ignoring `STORAGE_NOT_EXIST`; it means the target storage bucket\u002Fresource is not ready, not that the browser upload code should fabricate a URL.\n- On local Vite or dev-server tasks, forgetting to whitelist the exact current browser `host:port` before testing `app.uploadFile()`.\n- Treating CloudBase PG \u002F `pgstore` like the legacy NoSQL CloudBase storage. PG environments use a separate `pgstore` backend whose buckets are NOT auto-created from your old NoSQL bucket. If `pgstore` has no bucket, every upload returns `STORAGE_BUCKET_NOT_FOUND` and the SDK then issues `PUT https:\u002F\u002Fundefined\u002F` (visible in DevTools as `net::ERR_NAME_NOT_RESOLVED`). Treat bucket existence as a hard prerequisite, just like Supabase: in Supabase Storage every upload must target an already-created bucket; CloudBase PG follows the same model.\n\n### Minimal checklist\n\n- Confirm the caller is a browser\u002FWeb app.\n- Initialize the Web SDK once.\n- Confirm CloudBase storage exists in the current environment before testing upload. Use available MCP management\u002Fquery tools to inspect or create\u002Fselect the storage bucket when the environment has no default bucket. **In a PG \u002F pgstore environment, the legacy NoSQL bucket from `DescribeEnvs` does NOT count as a usable pgstore bucket; create one explicitly before any browser upload. The legacy NoSQL bucket itself is still fine for legacy `app.uploadFile()` flows that already target it — PG and NoSQL storage coexist; this skill applies to BOTH.**\n- Check security-domain\u002FCORS requirements.\n- Pick the right storage method before coding.\n\n### Local dev recipe\n\nWhen the app runs on a local browser origin and must upload files from the frontend:\n\n1. Use `queryEnv` with `action=\"domains\"` to inspect the current security-domain whitelist.\n2. Convert the browser origin into the CloudBase whitelist entry format:\n   - Browser origin `http:\u002F\u002F127.0.0.1:4173` -> whitelist entry `127.0.0.1:4173`\n   - Browser origin `http:\u002F\u002Flocalhost:5173` -> whitelist entry `localhost:5173`\n3. If the exact current host entry is missing, call `envDomainManagement` with `action=\"create\"` and add that host entry before relying on `app.uploadFile()`.\n4. If the runtime port may change between runs, do not assume any fixed default port list is sufficient. Re-check the actual browser origin you are really using for testing or final validation, then add that exact `host:port`.\n5. Tell the user that security-domain changes may take a few minutes to propagate; poll `queryEnv(action=\"domains\")` rather than blind-sleeping for a fixed long interval.\n6. Only after that should you implement and test browser-side `app.uploadFile()` flows.\n\nIf `app.uploadFile()` returns `STORAGE_NOT_EXIST`, stop editing frontend code and fix the environment-side storage resource first. Re-check the environment storage list, create or select an available bucket if the task allows it, then retry the same SDK upload flow.\n\nIf the task uses browser-side file upload, treat this as a prerequisite rather than an optional cleanup.\n\n### Bucket existence prerequisite (mandatory before any upload code)\n\nJust like Supabase Storage, CloudBase Storage requires the target bucket to exist before any client-side upload. This is true for both legacy CloudBase NoSQL storage (`STORAGE_NOT_EXIST`) and the newer PG \u002F `pgstore` backend (`STORAGE_BUCKET_NOT_FOUND`).\n\nMental model parity with Supabase:\n\n| Step | Supabase | CloudBase |\n| ---- | -------- | --------- |\n| Create bucket | `supabase.storage.createBucket('covers', { public: true })` (admin-side, with service role) | In PG mode, create a `storage.buckets` bucket through PG storage HTTP API \u002F CLI \u002F console \u002F SQL on `storage.buckets` when appropriate. The browser SDK cannot create one. |\n| Upload | `supabase.storage.from('covers').upload('a.png', file)` | **PG 模式**: `app.storage.from('covers').upload('a.png', file)` — `from(bucketName)` 指定 pgstore 存储桶。\u003Cbr>**非 PG 模式**: `app.storage.from().upload('covers\u002Fa.png', file)` — bucket 名作为路径第一段。|\n| Bucket missing error | `Bucket not found` | Browser sees `STORAGE_BUCKET_NOT_FOUND` (PG) or `STORAGE_NOT_EXIST` (NoSQL), then a follow-up `PUT https:\u002F\u002Fundefined\u002F` because the SDK still tries to PUT a missing `metadata.url`. |\n\nRequired pre-upload steps in any task that needs browser uploads:\n\n1. List existing buckets first. For PG \u002F pgstore, the legacy NoSQL bucket (the `6d63-…-1409864723` shape returned by `DescribeEnvs.Storages[]`) is NOT a valid pgstore bucket — do not assume it works.\n2. If no usable bucket exists for the upload target (e.g. `covers`), create one through the PG storage management surface BEFORE editing frontend upload code. Adding `covers` as a path prefix in code does not auto-create a bucket.\n3. After creating the bucket, the upload pattern depends on environment:\n   - **PG \u002F pgstore**: `app.storage.from('covers').upload('\u003Cfile>', file)` — bucket 名传入 `from()`\n   - **Non-PG (NoSQL)**: `app.storage.from().upload('covers\u002F\u003Cfile>', file)` — bucket 名作为路径第一段\n4. If you see `net::ERR_NAME_NOT_RESOLVED` going to `https:\u002F\u002Fundefined\u002F` in DevTools, that is the SDK reacting to a missing `metadata.url` field — almost always because the bucket does not exist or the SDK request was rejected upstream. Inspect the failed `POST ...\u002Fv1\u002Fstorages\u002Fget-objects-upload-info` response in DevTools first; the `code` field (e.g. `STORAGE_BUCKET_NOT_FOUND`, `STORAGE_CONTENT_LENGTH_REQUIRED`, `INVALID_PARAM`) tells you exactly what to fix.\n\nDo not silently swallow upload failures. If `uploadCoverImage()` rejects, the parent `createArticle()` MUST also reject — never proceed to `db.from(...).insert(...)` with a fabricated URL or a placeholder, and never let the UI show a success toast.\n\n### ⚠️ PG mode upload: use `app.storage.from('bucket')`, NOT `app.uploadFile()`\n\nIn PG \u002F pgstore environments, use `app.storage.from('covers').upload(key, file)` for uploads and `app.storage.from('covers').createSignedUrl(path, expiresIn)` for getting access URLs.\n\nDo NOT use the legacy NoSQL APIs in PG mode:\n- ❌ `app.uploadFile()` — 这是旧 NoSQL 的上传 API\n- ❌ `app.getTempFileURL()` — 这是旧 NoSQL 的获取 URL 方式\n- ❌ `app.storage.from().upload('covers\u002Ffile', file)` — 没有传 bucket 名\n\nUse instead:\n- ✅ `app.storage.from('covers').upload('file', file)` — PG 模式上传\n- ✅ `app.storage.from('covers').createSignedUrl('file', 3600)` — 获取签名 URL（返回 `fullSignedURL` 字段）\n\n**Return shapes differ between modes (v3 SDK) — copy the right column:**\n\n| call | 传统模式 (`from()` 无参, `cloud:\u002F\u002F` fileID) | PG 模式 (`from('bucket')`, bucket 内对象名) |\n|---|---|---|\n| `upload(path, file)` | `{ data: { id, path, fullPath } }`；`upsert` 默认 **true** | `{ data: { id, ... } }`；`upsert` 默认 **false** |\n| `createSignedUrl(path, expiresIn)` | `await` → `{ data: { signedUrl } }` | `await` → `{ data: { fullSignedURL } }` |\n| `getPublicUrl(path)` | `await` → `{ data: { publicUrl } }` | **同步调用（不 await）** → `{ data: { publicUrl } }` |\n\nSource: [webv3\u002Fclassic\u002Fstorage.md](https:\u002F\u002Fdocs.cloudbase.net\u002Fapi-reference\u002Fwebv3\u002Fclassic\u002Fstorage.md) · [webv3\u002Fstorage.md](https:\u002F\u002Fdocs.cloudbase.net\u002Fapi-reference\u002Fwebv3\u002Fstorage.md)（raw markdown）。\n\n### PG mode URL resolution: 公开桶直链 vs 签名 URL\n\n| Bucket 类型 | URL 策略 | 代码 |\n|---|---|---|\n| 公开桶（`storage.buckets.public = true`） | 直链，无需登录态，可直接进 `\u003Cimg src>` | `app.storage.from('covers').getPublicUrl('a.png')` → `{ data: { publicUrl } }` |\n| 私有桶 | 签名 URL，带过期时间 | `app.storage.from('covers').createSignedUrl('a.png', 3600)` |\n\n- 公开桶直链能否访问取决于 `storage.objects` 的 RLS SELECT 策略是否放行 anon —— 建桶 SQL 与策略模板见 `postgresql-development-cloudbase\u002Freferences\u002Fstorage-pg.md` \"Public-read bucket template\"。\n- 展示层做 `onerror` 兜底（直链被策略拦下时降级到签名 URL），不要硬依赖单一取址流程。\n- 业务表只存 bucket + key（或 SDK 解析出的最终 URL），不要在浏览器手工拼接 URL。\n\n### Post-bucket: storage RLS (mandatory in PG \u002F pgstore environments)\n\nIn **PG \u002F pgstore** environments, storage access control is enforced through **PostgreSQL Row Level Security (RLS) on `storage.buckets` \u002F `storage.objects`** — exactly like Supabase Storage. These tables are already granted to `anon`, `authenticated`, and `service_role`; RLS is the permission gate. Traditional storage permission labels (`READONLY` \u002F `PRIVATE` \u002F `CUSTOM`) and JSON storage safe rules do not apply. The default RLS policy is deny all, so even if the bucket exists, `app.storage.from('covers').upload()` from a browser will fail with `STORAGE_PERMISSION_DENIED` unless you configure policies.\n\nUse `managePgDatabase(action=\"execute\", confirm=true)` to run the following SQL after creating the bucket:\n\n```sql\nALTER TABLE storage.objects ENABLE ROW LEVEL SECURITY;\n\n-- Allow authenticated users to upload files\nCREATE POLICY \"authenticated_upload\" ON storage.objects\n  FOR INSERT TO authenticated\n  WITH CHECK (true);\n\n-- Allow authenticated users to read\u002Fdownload files\nCREATE POLICY \"authenticated_read\" ON storage.objects\n  FOR SELECT TO authenticated\n  USING (true);\n\n-- Optional: allow users to update\u002Fdelete their own files\nCREATE POLICY \"users_manage_own\" ON storage.objects\n  FOR UPDATE TO authenticated\n  USING (auth.uid() = owner_id)\n  WITH CHECK (auth.uid() = owner_id);\n```\n\nKey points:\n- `storage.objects` RLS is **separate** from CloudBase legacy NoSQL storage security rules (`managePermissions` \u002F `ModifyStorageSafeRule`). In PG mode, always configure storage RLS via PG SQL, not the legacy security rule API.\n- Without these policies, the browser receives `STORAGE_PERMISSION_DENIED` when calling `app.storage.from('covers').upload()` in PG mode.\n- Use `IF NOT EXISTS` in a `DO $$` block when re-applying to avoid \"policy already exists\" errors on re-run.\n\n## Overview\n\nUse this skill for **browser-side cloud storage operations** through the CloudBase Web SDK.\n\nTypical tasks:\n\n- upload files from a browser\n- generate temporary download URLs\n- delete files\n- trigger browser downloads\n\n## SDK initialization\n\nInit reference: [webv3\u002Finitialization.md](https:\u002F\u002Fdocs.cloudbase.net\u002Fapi-reference\u002Fwebv3\u002Finitialization.md)\n\n```javascript\nimport cloudbase from \"@cloudbase\u002Fjs-sdk\";\n\nconst app = cloudbase.init({\n  env: \"your-env-id\",\n  accessKey: import.meta.env.VITE_PUBLISHABLE_KEY, \u002F\u002F publishable key — auto-provisioned, see below\n});\n```\n\nInitialization rules:\n\n- **Publishable key auto-provisioning (do not ask the user):** browser-side storage requests are data-plane calls that require a publishable `accessKey`. Before writing client code, call `queryAppAuth(action=\"getPublishableKey\")`; if empty, call `manageAppAuth(action=\"ensurePublishableKey\")`; then write the key to `.env.local` as `VITE_PUBLISHABLE_KEY` (create the file if missing) and read it via `import.meta.env.VITE_PUBLISHABLE_KEY`. Never hardcode the key into source files. Only fall back to the console (`https:\u002F\u002Ftcb.cloud.tencent.com\u002Fdev?envId={env}#\u002Fenv\u002Fapikey`) if both MCP calls fail.\n- Use synchronous initialization with a shared app instance.\n- Do not re-initialize in every component.\n- If the operation depends on user identity, handle auth before storage operations.\n\n## Method routing\n\n- Upload from browser -> `app.uploadFile()`\n- Temporary preview\u002Fdownload URL -> `app.getTempFileURL()`\n- Delete existing files -> `app.deleteFile()`\n- Trigger browser download -> `app.downloadFile()`\n\n## Upload\n\n```javascript\nconst result = await app.uploadFile({\n  cloudPath: \"uploads\u002Favatar.jpg\",\n  filePath: selectedFile\n});\n```\n\n### Upload rules\n\n- `cloudPath` must include the filename.\n- Use `\u002F` to create folder structure.\n- **In a CloudBase PG \u002F pgstore environment**, the `from(bucketName)` argument is used as the bucket name (e.g. `from('covers')`), and `upload(key, file)` takes a key without bucket prefix. The bucket must already exist. Same model as Supabase Storage — never upload into a not-yet-created bucket.\n- Validate file type and size before upload.\n- Show upload progress for larger files when UX matters.\n- On local dev origins, confirm the exact frontend origin already exists in environment security domains before assuming the upload path is usable.\n- Match against the whitelist entry format returned by `queryEnv(action=\"domains\")`, which is typically `host:port` instead of a full `http:\u002F\u002F...` URL.\n- If the environment has no storage bucket or the SDK returns `STORAGE_NOT_EXIST` \u002F `STORAGE_BUCKET_NOT_FOUND`, use CloudBase management\u002FMCP storage tools to create or choose a bucket before retrying. Do not treat this as a successful optional upload.\n- After `app.uploadFile()` succeeds, do **not** fabricate a public-looking URL by concatenating `envId`, bucket domain, or `cloudPath`. Use the returned `fileID` with `app.getTempFileURL()` and store or display the SDK-resolved URL instead.\n\n### Progress example\n\n```javascript\nawait app.uploadFile({\n  cloudPath: \"uploads\u002Favatar.jpg\",\n  filePath: selectedFile,\n  onUploadProgress: ({ loaded, total }) => {\n    const percent = Math.round((loaded * 100) \u002F total);\n    console.log(percent);\n  }\n});\n```\n\n## Temporary URLs\n\n```javascript\nconst result = await app.getTempFileURL({\n  fileList: [\n    {\n      fileID: \"cloud:\u002F\u002Fenv-id\u002Fuploads\u002Favatar.jpg\",\n      maxAge: 3600\n    }\n  ]\n});\n```\n\nUse temp URLs when the browser needs to preview or download private files without exposing a permanent public link.\n\nTypical upload + preview flow:\n\n```javascript\nconst uploadResult = await app.uploadFile({\n  cloudPath: \"uploads\u002Favatar.jpg\",\n  filePath: selectedFile\n});\n\nconst tempUrlResult = await app.getTempFileURL({\n  fileList: [{ fileID: uploadResult.fileID, maxAge: 3600 }]\n});\n\nconst previewUrl = tempUrlResult.fileList?.[0]?.tempFileURL || tempUrlResult.fileList?.[0]?.download_url;\nif (!previewUrl) {\n  throw new Error(\"Failed to resolve temporary file URL after upload\");\n}\n```\n\n## Delete files\n\n```javascript\nawait app.deleteFile({\n  fileList: [\"cloud:\u002F\u002Fenv-id\u002Fuploads\u002Fold-avatar.jpg\"]\n});\n```\n\nAlways inspect per-file results before assuming deletion succeeded.\n\n## Download files\n\n```javascript\nawait app.downloadFile({\n  fileID: \"cloud:\u002F\u002Fenv-id\u002Fuploads\u002Freport.pdf\"\n});\n```\n\nUse this for browser-initiated downloads. For programmatic rendering or preview, prefer `getTempFileURL()`.\n\n## Security-domain reminder\n\nTo avoid CORS problems, add your frontend domain in CloudBase security domains. In MCP-enabled workflows, prefer checking and updating this through tools before coding browser uploads.\n\n```json\n{ \"tool\": \"queryEnv\", \"action\": \"domains\" }\n```\n\nUse the actual browser origin when deciding what to add. If the page is running on a custom domain or a local dev port, add that exact `host:port` value instead of guessing from a hard-coded list.\n\n```json\n{\n  \"tool\": \"envDomainManagement\",\n  \"action\": \"create\",\n  \"domains\": [\"\u003Cactual-browser-host>:\u003Cactual-browser-port>\"]\n}\n```\n\nMatch the real browser origin to the whitelist entry format returned by `queryEnv(action=\"domains\")`. For local Vite and preview servers, the port can vary between runs, so avoid assuming any fixed default port is sufficient.\n\nTypical examples:\n\n- `\u003Cyour-local-host>:\u003Cactual-port>`\n- `\u003Cyour-custom-domain>`\n\n## Best practices\n\n1. Use a clear folder structure such as `uploads\u002F`, `avatars\u002F`, `documents\u002F`.\n2. Validate file size and type in the browser before upload.\n3. Use temporary URLs with reasonable expiration windows.\n4. Clean up obsolete files instead of leaving orphaned storage objects.\n5. Route privileged batch-management tasks to backend or MCP flows instead of browser direct access.\n\n## Error handling\n\n```javascript\ntry {\n  const result = await app.uploadFile({\n    cloudPath: \"uploads\u002Ffile.jpg\",\n    filePath: selectedFile\n  });\n  console.log(result.fileID);\n} catch (error) {\n  console.error(\"Storage operation failed:\", error);\n}\n```\n",{"name":5,"license":14,"version":23,"alwaysApply":19,"description":7},"2.36.2","main","33b6151ccee9aa0816c6f32d021be77d82772755","connectors\u002Fcloudbase\u002Fskills\u002Freferences\u002Fcloud-storage-web",138,"https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills","https:\u002F\u002Fgithub.com\u002Finfometa","2026-11-11 03:15:35",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add infometa\u002Fworkbuddyskills --skill cloud-storage-web",{"tool":37,"command":38},"bunx","bunx skills add infometa\u002Fworkbuddyskills --skill cloud-storage-web",{"tool":40,"command":41},"pnpm","pnpm dlx skills add infometa\u002Fworkbuddyskills --skill cloud-storage-web","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills\u002Fblob\u002Fmain\u002Fconnectors\u002Fcloudbase\u002Fskills\u002Freferences\u002Fcloud-storage-web\u002FSKILL.md",true,[],[46,53,60,67,74,83],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":18},"01M7A1EC013S1PBBTSH2PA2S7D","yingmi-skill","当用户需要查询基金、策略、公告、财经资讯，做资产配置、组合诊断、风险回测、现金流分析，或生成图表、PDF 时，优先使用本 Skill 获取真实数据与可执行能力。","https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills\u002Fblob\u002Fmain\u002Fskills\u002Fyingmi-skill\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":18},"01M7A194T67P6NRVYK8KCTH3CH","web-access","所有联网操作必须通过此 skill 处理，包括：搜索、网页抓取、登录后操作、网络交互等。","https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-access\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":18},"01M7A14FATMDD6FK8QAGXY5GVR","tencentmap-map-assistant","腾讯位置服务·地图助手 Skill，一句自然语言调用腾讯地图全套能力，无需开发者账号、开箱即用。提供 AI 旅游攻略、地点搜索（含评分\u002F人均\u002F营业时间）、关键词提示、路线规划（驾车\u002F步行\u002F公交\u002F骑行）、地址解析与逆解析、行政区划、IP 定位、距离计算、天气查询，并可将行程或多 POI 渲染成网页地图。涉及找地点、规划路线、旅游行程、查天气、坐标转换等出行场景时使用。","https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills\u002Fblob\u002Fmain\u002Fskills\u002Ftencentmap-map-assistant\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M7A0SX4XW5053MZ2S921EDH2","skill-scanner","Scan any agent skill for security risks before you install or use it. Powered by Tencent Zhuque Lab A.I.G (AI-Infra-Guard). 100% local static analysis — no file contents or credentials leave your device. Compatible with CodeBuddy, Cursor, Windsurf, Claude Code, OpenClaw and more. Triggers on: 这个 skill 安全吗, skill 安全扫描, 检查 skill 安全, audit skill, scan skill, check skill safety, analyze skill, inspect skill, verify skill, skill security, skill supply chain. Do NOT trigger for general agent usage, full system health checks, project debugging, or normal development.","https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills\u002Fblob\u002Fmain\u002Fskills\u002Fskill-scanner\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":78,"licenseFileUrl":79,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":18},"01M7A0SQC2CZB3450G8471673M","skill-creator","Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends agent capabilities with specialized knowledge, workflows, or tool integrations.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills\u002Fblob\u002Fmain\u002Fskills\u002Fskill-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills\u002Fblob\u002Fmain\u002Fskills\u002Fskill-creator\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":18},"01M7A0RHV7BKS7DFQF9X9QCCNN","shader-dev","Comprehensive GLSL shader techniques for creating stunning visual effects — ray marching, SDF modeling, fluid simulation, particle systems, procedural generation, lighting, post-processing, and more.","https:\u002F\u002Fgithub.com\u002Finfometa\u002Fworkbuddyskills\u002Fblob\u002Fmain\u002Fskills\u002Fshader-dev\u002FSKILL.md",[],[]]