一键导入
upload-download
Upload and download Swarm data/files with bee-js or swarm-cli across Node.js/browser workflows, with prerequisite checks and common fixes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Upload and download Swarm data/files with bee-js or swarm-cli across Node.js/browser workflows, with prerequisite checks and common fixes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Guide to Swarm ACT encryption and access control: create grantees, upload protected data, grant/revoke access, and troubleshoot not-found/history issues.
Build and publish a Swarm blog with a permanent feed-manifest URL, post management workflow, and optional ENS domain mapping.
Scaffold a Swarm app or add bee-js to an existing project, with core upload/download patterns and node-compatibility guidance.
Answer Swarm conceptual questions from official docs with source links; use for APIs, behavior, configuration, and architecture clarifications.
Create and manage Swarm feeds for stable, updateable URLs using bee-js or swarm-cli, including manifest creation and feed updates.
Deploy and update static websites on Swarm via one-off or feed-based publishing, with optional ENS integration and stamp lifecycle notes.
基于 SOC 职业分类
| name | upload-download |
| description | Upload and download Swarm data/files with bee-js or swarm-cli across Node.js/browser workflows, with prerequisite checks and common fixes. |
| user-invocable | true |
Guide a developer through uploading and downloading data on Swarm. Requires a running Bee light node and a postage stamp.
When presenting to the user, use consistent labels before each code block:
filename: — file contents the user should write to diskAdd a --- horizontal rule before each labeled code block to visually separate it from surrounding text.
Silently check node status (curl -s http://localhost:1633/node) and stamp availability (swarm-cli stamp list). If the node is down, offer to walk through /setup-bee-interactive. If no usable stamp exists, route to /stamps.
npm install @ethersphere/bee-jsnpm install -g @ethersphere/swarm-cliimport { Bee } from "@ethersphere/bee-js";
import { readFile } from "node:fs/promises";
const bee = new Bee("http://localhost:1633");
const data = await readFile("./hello.txt");
const { reference } = await bee.uploadFile(batchId, data, "hello.txt", {
contentType: "text/plain",
});
console.log("Reference:", reference.toHex());
import { Bee } from "@ethersphere/bee-js";
const bee = new Bee("http://localhost:1633");
const file = new File(["Hello Swarm!"], "hello.txt", { type: "text/plain" });
const { reference } = await bee.uploadFile(batchId, file);
console.log("Reference:", reference.toHex());
swarm-cli upload ./hello.txt --stamp <BATCH_ID>
import { Bee } from "@ethersphere/bee-js";
const bee = new Bee("http://localhost:1633");
const files = [
new File(["<h1>Hello Swarm</h1>"], "index.html", { type: "text/html" }),
new File(["body{font-family:sans-serif}"], "assets/main.css", { type: "text/css" }),
];
const res = await bee.uploadFiles(batchId, files);
console.log("Collection ref:", res.reference.toHex());
import { Bee } from "@ethersphere/bee-js";
const bee = new Bee("http://localhost:1633");
const res = await bee.uploadFilesFromDirectory(batchId, "./my-files");
console.log("Collection reference:", res.reference.toHex());
swarm-cli upload ./my-files --stamp <BATCH_ID>
const { reference } = await bee.uploadData(batchId, "Hello Swarm");
console.log("Reference:", reference.toHex());
echo "Hello Swarm" | swarm-cli upload --stdin --stamp <BATCH_ID>
Windows (PowerShell) alternative:
"Hello Swarm" | swarm-cli upload --stdin --stamp <BATCH_ID>
const file = await bee.downloadFile(reference);
console.log(file.name);
console.log(file.contentType);
console.log(file.data.toUtf8());
const page = await bee.downloadFile(collectionReference, "index.html");
const style = await bee.downloadFile(collectionReference, "assets/main.css");
const data = await bee.downloadData(reference);
console.log(data.toUtf8());
# Save to file in current directory (filename = reference hash)
swarm-cli download <REFERENCE>
# Print to stdout (single files only)
swarm-cli download <REFERENCE> --stdout
| Action | Method | Endpoint |
|---|---|---|
| Upload raw data | POST | /bytes |
| Download raw data | GET | /bytes/{reference} |
| Upload file/collection | POST | /bzz |
| Download file/collection | GET | /bzz/{reference} |
Headers for upload:
Swarm-Postage-Batch-Id — requiredContent-Type — recommended| Error | Fix |
|---|---|
| "stamp not usable" | Stamp hasn't propagated yet — wait 2-3 minutes after buying |
| "insufficient funds" | Wallet needs xBZZ — see /setup-bee-interactive funding section |
| Connection refused | Node isn't running — route to /setup-bee-interactive |
| 402 response | No usable stamp — route to /stamps |
| "not found" on download | Content may have expired, or reference is wrong |
| Other errors | Route to /troubleshoot |
For any conceptual or technical question not covered by the steps above, invoke /docs to find the relevant authoritative source rather than answering from prior knowledge.