Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

upstash-blob-js

БесплатноБез исполняемых скриптовНе проверен

Work with the @upstash/blob TypeScript/JavaScript SDK for S3-compatible object storage with direct browser uploads, presigned URLs, multipart, and signed…

upstashот upstash★ 37 звёзд на GitHub

Об этом скилле

@upstash/blob SDK

S3-compatible object storage. Bucket runs on your server; uploadHandler plus React hooks upload from the browser straight to storage so the bytes never pass through your app.

Bundled docs and source

The @upstash/blob npm package includes docs in node_modules/@upstash/blob/docs/ and readable TypeScript source in node_modules/@upstash/blob/src/. Before writing or debugging SDK code, read and search the relevant docs and source.

Install & Setup

npm install @upstash/blob

Create a bucket in the console and set UPSTASH_BLOB_TOKEN. The token is a bearer secret for the whole bucket — keep it server side, never in NEXT_PUBLIC_ or any bundler-inlined variable.

A bucket is public (every object has a URL) or private (no URL; reads go through signedReadUrl). That is a console setting, not a client option — the SDK learns it from the backend.

import { Bucket } from "@upstash/blob"

export const bucket = Bucket.fromEnv()                          // reads UPSTASH_BLOB_TOKEN
Bucket.fromEnv({ cache: "immutable" })                        // default variable, plus options
Bucket.fromEnv("MEDIA_TOKEN", { cache: "immutable" })           // another variable, plus options
new Bucket({ token: env.UPSTASH_BLOB_TOKEN })                   // Workers: no process.env
Bucket.fromEnv({ retry: { retries: 4, backoff: (n) => 250 * 2 ** n } })   // or retry: false

Failed requests (5xx, 429, dropped connection) are retried twice by default with jittered backoff. retry changes the count and the wait in ms (n counts from 0; a Retry-After from the service wins), and retry: false sends each request once.

Writing

const blob = await bucket.put("reports/q3.pdf", pdf, { contentType: "application/pdf" })
blob.url            // public URL, undefined on a private bucket
blob.versionedUrl   // url + ?v=<etag>, changes whenever the bytes do
blob.etag           // what ifUnchanged takes

Bodies: Request, Blob/File, ArrayBuffer, typed array, string, ReadableStream. A stream carries no length — pass size (exact, streams through) or maxSize (buffers up to the cap), or put throws length_required.

Option Default What it does
contentType the body's, else application/octet-stream What the object is stored as
contentTypes any Allow list, e.g. ["image/*", "application/pdf"]
maxSize none Refuse a bigger body with too_large
cache bucket default Cache-Control stored with the object
metadata none x-amz-meta-*; printable ASCII values, keys are read back lowercased
allowOverwrite true false refuses if something is there (already_exists)
ifUnchanged none An etag; fails with conflict if it changed
multipart '16mb' Threshold for going up in parts; true/false force it

Sizes are decimal: '20mb' is 20,000,000 bytes, too small for a 20 MiB file. Binary units are explicit: '20mib' is 20 * 1024 * 1024. Unit names ignore case.

import { uniquePath } from "@upstash/blob"

uniquePath(`${user.id}/${file.name}`)   // 'u7/Holiday Pic-3xK9mBqR.png'

uniquePath adds a random suffix to the final filename, before its extension, so two uploads of photo.png never collide. Everything else is kept as given (case, spaces, Unicode, slashes), so a value can add directories. Nothing is validated here: a path with . or .. segments is refused by the call that uses it (invalid_input from an upload route). Store the returned path and authorize reads and deletes against the stored owner and exact path.

bucket.copy(from, to, { contentType, cache, metadata }) and bucket.move(from, to, options) preserve source properties you omit. bucket.updateJson(path, fn, { maxAttempts: 6 }) retries a read-modify-write on conflict with backoff.

Reading

const res = await bucket.get("reports/q3.pdf")   // record + body: ReadableStream
const info = await bucket.info("reports/q3.pdf") // same record, no bytes (HEAD)
await bucket.exists("avatars/u7.png")            // boolean instead of a throw
const page = await bucket.list({ prefix: "avatars/", limit: 1000 })

get/info throw not_found. Nothing is buffered — wrap the stream to read it:

await new Response((await bucket.get("notes/1.md")).body).text()

list pages with page.cursor (set only while more remains) and carries no contentType or metadata. prefix is the only filter — keep your own table as the index and treat the bucket as storage, not a queryable store.

const { url, expiresAt } = await bucket.signedReadUrl("private/report.pdf", {
  expiresIn: "2m",
  downloadAs: "Report Q3.pdf",   // save under this name instead of rendering inline
})

A signed link lives at most 10 minutes (default 5 for a read); a longer expiresIn gets 10. Cache the link until expiresAt, never a deadline you compute. `await bucket.pub

Полный SKILL.md на GitHub

Установить upstash-blob-js в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл upstash-blob-js?

Work with the @upstash/blob TypeScript/JavaScript SDK for S3-compatible object storage with direct browser uploads, presigned URLs, multipart, and signed reads. Use when storing files or blobs, uploading avatars, images, videos, attachments or user documents, letting a browser upload straight to storage without proxying bytes through a server, generating public or time-limited signed URLs, serving private files, streaming large files with pause and resume, setting cache headers on stored objects, or reaching an S3-compatible bucket from the AWS SDK.

Как установить скилл upstash-blob-js?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл upstash-blob-js запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить upstash-blob-js с