跳到主内容
智客 ZICQ

技能库 智客分类:文档办公 netlify-blobs

净化集团

与Netlify Blobs存储并检索文件上传,图像,文档,JSON等无结构的数据,以及缓存类状态. 它是从函数、边函数和构建插件中访问的零配置密钥/值存储 。 当您处理一个文件或图像上传, 坚持像站点映射或处理过的媒体一样的背景函数输出, 缓存 API 响应, 存储每个部署的资产, 或需要从一个没有服务器的函数中获取一个简单的密钥/ 值存储时, 联系到此 。 覆盖创建站点并部署存储,读取和写取值和JSON,列出带有元数据,原子条件书写,一致性模式,区域选择,以及基于文件的上传. 不适用于每个用户,交易,或关系数据——为此使用Netlify DB.

2413 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

与Netlify Blobs存储并检索文件上传,图像,文档,JSON等无结构的数据,以及缓存类状态. 它是从函数、边函数和构建插件中访问的零配置密钥/值存储 。 当您处理一个文件或图像上传, 坚持像站点映射或处理过的媒体一样的背景函数输出, 缓存 API 响应, 存储每个部署的资产, 或需要从一个没有服务器的函数中获取一个简单的密钥/ 值存储时, 联系到此 。 覆盖创建站点并部署存储,读取和写取值和JSON,列出带有元数据,原子条件书写,一致性模式,区域选择,以及基于文件的上传. 不适用于每个用户,交易,或关系数据——为此使用Netlify DB.

何时用

官方 description 未单独写出 Use when。按规范,代理会在用户任务与这段 description 的关键词匹配时激活本技能。

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Netlify Blobs、Footguns (read first)、Store selection、Common tasks、API surface、Atomic conditional writes。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

Store and retrieve unstructured data like file uploads, images, documents, JSON, and cache-like state with Netlify Blobs. It is a zero-config key/value store accessible from Functions, Edge Functions, and Build Plugins. Reach for this when you handle a file or image upload, persist Background Function output like sitemaps or processed media, cache API responses, store per-deploy assets, or need a simple key/value store from a serverless function. Covers creating site and deploy stores, reading and writing values and JSON, listing keys with metadata, atomic conditional writes, consistency modes, region selection, and file-based uploads. Not for per-user, transactional, or relational data — use Netlify DB for that.

Netlify BlobsFootguns (read first)Store selectionCommon tasksAPI surfaceAtomic conditional writesListing hierarchicallyPaginationConditional requests / local cachingConfigurationConsistencyRegions

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
netlify-blobs
description
Store and retrieve unstructured data like file uploads, images, documents, JSON, and cache-like state with Netlify Blobs. It is a zero-config key/value store accessible from Functions, Edge Functions, and Build Plugins. Reach for this when you handle a file or image upload, persist Background Function output like sitemaps or processed media, cache API responses, store per-deploy assets, or need a simple key/value store from a serverless function. Covers creating site and deploy stores, reading and writing values and JSON, listing keys with metadata, atomic conditional writes, consistency modes, region selection, and file-based uploads. Not for per-user, transactional, or relational data — use Netlify DB for that.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「netlify-blobs」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-e66e793acd68d393-%E5%87%80%E5%8C%96%E9%9B%86%E5%9B%A2.html
请存为 .cursor/skills/netlify-blobs/SKILL.md 或 .claude/skills/netlify-blobs/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/netlify/context-and-tools' --list

npx skills add 'https://github.com/netlify/context-and-tools' --skill 'netlify-blobs'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: netlify-blobs description: Store and retrieve unstructured data like file uploads, images, documents, JSON, and cache-like state with Netlify Blobs. It is a zero-config key/value store accessible from Functions, Edge Functions, and Build Plugins. Reach for this when you handle a file or image upload, persist Background Function output like sitemaps or processed media, cache API responses, store per-deploy assets, or need a simple key/value store from a serverless function. Covers creating site and deploy stores, reading and writing values and JSON, listing keys with metadata, atomic conditional writes, consistency modes, region selection, and file-based uploads. Not for per-user, transactional, or relational data — use Netlify DB for that. --- # Netlify Blobs Modern syntax — import from `@netlify/blobs`, open a store, operate on it: ```ts import { getStore } from "@netlify/blobs"; const store = getStore("file-uploads"); // site-wide await store.set(key, value, { metadata: { … } }); const entry = await store.get(key); // null if missing ``` Deploy-specific isolation: ```ts import { getDeployStore } from "@netlify/blobs"; const store = getDeployStore("file-uploads"); ``` Requires Fetch API (Node.js 18+). **Functions written in Go cannot access Blobs.** Not for per-user/transactional/relational data — use Netlify DB. ## Footguns (read first) - **Site-scoped stores (`getStore`) are shared across ALL deploy contexts.** Code on a deploy preview reads, overwrites, and deletes production data. Never run destructive tests or seed throwaway data from previews — use `getDeployStore()` or a context-specific store name for isolation. - **Site-wide stores do NOT follow your functions region.** `getStore` defaults to `us-east-2` regardless of where your functions run — no error or warning is raised. To use another region you must pass `region` on **every** `getStore` call for that store (reads, writes, deletes); a call that omits it hits `us-east-2` and won't see data held elsewhere. Changing a store's region does not migrate data. - **Last write wins.** No concurrency control. Do not build counters, balances, or read-modify-write logic on a blob key — even with `onlyIfMatch` retries. That's transactional data; use Netlify DB. - **No built-in access control.** The serving function is the gate. Default to private: gate reads behind an authenticated function rather than exposing blobs publicly. Treat user input as unsafe — don't serve arbitrary caller-supplied keys; scope keys with something callers can't tamper with. - **Eventual consistency by default** — updates/deletions take up to 60s to propagate. Pass `consistency: "strong"` if a read must see the latest write immediately (slower reads). - **When an operation fails, surface the error and read the function logs.** Do not invent REST endpoints or side-channel APIs to retry. ## Store selection - `getStore(name)` — site-wide; persists across deploys, readable from all contexts. - `getDeployStore(name)` — scoped to one deploy; use for isolation and for any write from a **Build Plugin** or file-based upload. - **Build Plugins:** can *read* from any of the site's stores, but can *write* only to deploy-specific stores (`getDeployStore`). Both accept a positional form `getStore(name, { region, siteID, token })` / `getDeployStore(name, { deployID, region, siteID, token })` or an object form `getStore({ name, consistency, region, siteID, token, fetch })`. `siteID`, `deployID`, and `token` are set automatically inside Functions/Edge Functions/Build Plugins; supply them explicitly only to override (e.g. `siteID` of another site you own). `region` is auto-set **only** for `getDeployStore` (defaults to your functions region); for `getStore` it is **not** auto-set and defaults to `us-east-2`. Site ID = API `site_id` = `NETLIFY_SITE_ID` = the UI's **Project ID**. ## Common tasks Persist an upload (Function): ```ts import { getStore } from "@netlify/blobs"; import type { Context } from "@netlify/functions"; import { v4 as uuid } from "uuid"; export default async (req: Request, context: Context) => { const form = await req.formData(); const file = form.get("file") as File; const uploads = getStore("file-uploads"); await uploads.set(uuid(), file, { metadata: { country: context.geo.country.name } }); return new Response("Submission saved"); }; ``` Persist JSON — use `setJSON`: ```ts const uploads = getStore("json-uploads"); await uploads.setJSON(key, data, { metadata: { … } }); ``` Read a blob (null if missing): ```ts const entry = await uploads.get(key); if (entry === null) return new Response("Not found", { status: 404 }); return new Response(entry); ``` Read with metadata: ```ts const { data, metadata } = await uploads.getWithMetadata(key); ``` Delete / delete a whole store: ```ts await uploads.delete(key); const { deletedBlobs } = await uploads.deleteAll(); // 0 if store didn't exist ``` ## API surface Store-opening: `getStore`, `getDeployStore`, `listStores` (imported from `@netlify/blobs`). Store instance methods: `get`, `getWithMetadata`, `getMetadata`, `set`, `setJSON`, `list`, `delete`, `deleteAll`. **`set(key, value, { metadata, onlyIfMatch, onlyIfNew })`** — `value` is `ArrayBuffer | Blob | string`. Overwrites by default. Resolves `{ modified, etag }`. **`setJSON(key, value, { metadata, onlyIfMatch, onlyIfNew })`** — same, `value` any JSON-serializable. **`get(key, { consistency, type })`** — `type` one of `text` (default) / `json` / `arrayBuffer` / `blob` / `stream`. Resolves the value, or `null` if missing. **`getWithMetadata(key, { consistency, etag, type })`** — resolves `{ data, etag, metadata }`, or `null` if missing. If `etag` matches the passed value, `data` is `null` (cache still fresh). **`getMetadata(key, { consistency, etag, type })`** — resolves `{ metadata, etag }`, or `null` if missing. Check existence without downloading the blob. **`list({ directories, paginate, prefix })`** — resolves `{ blobs: [{ etag, key }], directories: string[] }`. **`listStores({ paginate })`** — resolves `{ stores: string[] }`. Does **not** include deploy-specific stores. **`delete(key)`** — resolves `undefined`. **`deleteAll()`** — resolves `{ deletedBlobs }`; deleting a store is deleting all its blobs. ### Atomic conditional writes - `onlyIfNew: true` — write only if the key does not exist. - `onlyIfMatch: etag` — write only if current ETag matches (optimistic concurrency). - Inspect the returned `modified` boolean to detect success/failure. ```ts const { modified } = await emails.set("[email protected]", "Jane Doe", { onlyIfNew: true }); if (!modified) return new Response("Email already exists", { status: 400 }); ``` (These are for single-key create-if-absent / compare-and-set, not for building transactional counters.) ### Listing hierarchically Group keys with `/`. `list({ directories: true })` returns top-level `directories` plus root blobs. Drill in with `prefix` — **the prefix must include a trailing slash** (`"cats/"`), or keys like `catsuit` also match. ```ts const { blobs, directories } = await animals.list({ directories: true }); const cats = await animals.list({ directories: true, prefix: "cats/" }); ``` ### Pagination Server pages up to **1,000** entries (`list`) / **1,000** stores (`listStores`). Handled automatically by default; pass `paginate: true` for an `AsyncIterator`: ```ts for await (const entry of store.list({ paginate: true })) { console.log(entry.blobs); } ``` ### Conditional requests / local caching Pass a cached `etag` to `getWithMetadata`/`getMetadata`; if it matches, `data` is `null` (your copy is fresh). Compare the whole value including surrounding quotes and any weakness prefix. ## Configuration ### Consistency Default is **eventual** (single-region, edge-cached; propagation within 60s). Opt into **strong** per store or per read: ```ts const store = getStore({ name: "animals", consistency: "strong" }); // store level const dog = await store.get("dog", { consistency: "strong" }); // operation level ``` The Netlify CLI always uses strong consistency. ### Regions Valid regions (a **smaller** set than the [function regions](https://docs.netlify.com/build/functions/configuration#region)): `us-east-1`, `us-east-2`, `eu-central-1`, `ap-southeast-1`, `ap-southeast-2`. - **Deploy-specific stores** (`getDeployStore`) default to your functions region; `region` is auto-set in Functions/Edge Functions/Build Plugins. Override explicitly: ```ts const uploads = getDeployStore({ name: "file-uploads", region: "ap-southeast-2" }); ``` - **Site-wide stores** (`getStore`) default to `us-east-2` and do **not** follow your functions region. `region` is never auto-set here. ```ts const profiles = getStore({ name: "user-profiles", region: "eu-central-1" }); ``` **Gotcha — pass `region` on every call.** A site-wide store only reaches non-default-region data if **every** `getStore` call (reads, writes, deletes) passes the same `region`. Omit it and the call silently uses `us-east-2` — no error is raised. **Changing a store's region does not migrate data**: the store appears empty in the new region while the original data stays in the old one. To move data, copy each entry to a store opened in the new region, then delete from the old. ### Custom `fetch` If you can't use Node.js 18, supply your own `fetch`: ```ts const uploads = getStore({ fetch, name: "file-uploads" }); ``` ## File-based uploads (deploy-specific stores) For framework/tool authors integrating without a build plugin. Place blob files under `.netlify/blobs/deploy` in the site's base directory; Netlify uploads them (preserving directory structure) after the build, before the deploy. **Netlify deletes `.netlify/blobs/deploy` before each build** — files committed to the repo are NOT uploaded. You must create blob files *during* the build (build command or plugin). Attach metadata with a sibling JSON file prefixing the blob filename with `$` and ending `.json`: ``` .netlify/blobs/deploy/ ├─ dogs/ │ ├─ good-boy.jpg │ └─ $good-boy.jpg.json ├─ cat.jpg └─ mouse.jpg (no metadata) ``` Metadata files must be valid JSON or the deploy fails. Requires continuous deployment or CLI deploys. ## Deploy-specific store lifecycle - Kept in sync on rollback; cleaned up with automatic deploy deletion. - **Downloading a deploy does NOT download deploy-specific blobs.** - **Locking a published deploy does NOT prevent writing to its deploy-specific stores.** ## Expiration (no built-in TTL) Roll your own: `set` with a timestamp in metadata → `getWithMetadata` to check → `delete` if expired. ## CLI `netlify blobs:list/get/set/delete` exist for inspection — see the [CLI blobs command reference](https://cli.netlify.com/commands/blobs/) for details. The CLI always uses strong consistency and requires a site-wide store. ## Local development Netlify Dev uses a sandboxed local store: no file-based uploads, and you cannot read production data locally. ## Constraints - Store names: no `/` or `:`, max **64 bytes**. - Keys: non-empty, cannot start with `/`, any Unicode, max **600 bytes**. - Object max **5 GB**; metadata max **2 KB**. (Byte limits, not char counts — some UTF-8 chars are multi-byte.) - Blobs encrypted at rest and in transit; accessible only through your own site. - **Not** part of Netlify's HIPAA-compliant hosting offering. - Review any third-party build plugin's code before trusting it with blob access. ## Migration (`@netlify/blobs` 6.5.0 → 7.0.0) Site-wide stores written with v6.5.0 or earlier become inaccessible after upgrading (namespacing change). Migrate per store with the latest [Netlify CLI](https://docs.netlify.com/api-and-cli-guides/cli-guides/get-started-with-cli): ```sh netlify recipes blobs-migrate YOUR_STORE_NAME ``` Migrated stores are accessible with v7.0.0+. # Netlify house rules (blobs) These are org conventions, not docs facts — merged into the rendered skill by ctx-gen and never generated. Owned by the skills maintainer. 1. Blobs is not a database. For dynamic, per-user, or transactional data, use Netlify DB — Blobs is for objects, files, and cache-like state. 2. When a store operation fails, surface the error and read the function logs — do not invent REST endpoints or side-channel APIs to retry. 3. `netlify blobs:list/get/set/delete` exist for inspection; the CLI reference is their source of truth — link, don't restate. 4. Blobs have no built-in access control — the serving function is the gate. When in doubt, default to private: gate reads behind an authenticated function rather than exposing blobs publicly. 5. Site-scoped stores are shared across ALL deploy contexts — code on a deploy preview reads, overwrites, and deletes production data. Never run destructive tests or seed throwaway data from previews; use `getDeployStore()` or a context-specific store name for isolation. 6. Don't build counters, balances, or read-modify-write logic on a blob key — even with `onlyIfMatch` retries. That's transactional data; use Netlify DB. 7. Build plugins: state BOTH halves — they can read from any of the site's stores, but write only to deploy-specific stores (`getDeployStore`).

相关技能

文档办公

肿瘤Ontology

为结构化的代理内存和可堆肥技能所打入的知识图. 在创建/征服实体(Person, project, Task, Evention, Document)时使用,链接相关对象,强制约束,规划多步动作作为图变,或技能需要共享状态时使用. 触发到"记住","我知道什么","链接X到Y",…

文档办公

纳诺PdfNano Pdf

使用纳米-pdf CLI编辑带有自然语言指令的PDF.

文档办公

单词 / DOCXWord / DOCX

创建,检查,并编辑有可靠样式的Microsoft Word文档和DOCX文件,编号,跟踪更改,表格,章节,并进行相容性检查. 当 (1) 任务涉及 Word 或 ".docx " 时使用; (2) 文件包括跟踪的更改,评论,字段,表格,模板,或页面布局限制; (3) 文档必须在不…

文档办公

百度搜索Baidu Search

使用Baidu AI搜索引擎(BDSE)搜索网页. 用于实时信息、文件或研究专题.