cloud-storage-web
Complete guide for CloudBase cloud storage using Web SDK (@cloudbase/js-sdk) - upload, download, temporary URLs, file management, and best practices.
от LeoYeAI★ 2 236 звёзд на GitHub
Установить cloud-storage-web в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Cloud Storage Web SDK
Use this skill when building web applications that need to upload, download, or manage files using CloudBase cloud storage via the @cloudbase/js-sdk (Web SDK).
When to use this skill
Use this skill for file storage operations in web applications when you need to:
- Upload files from web browsers to CloudBase cloud storage
- Generate temporary download URLs for stored files
- Delete files from cloud storage
- Download files from cloud storage to local browser
Do NOT use for:
- Mini-program file operations (use mini-program specific skills)
- Backend file operations (use Node SDK skills)
- Database operations (use database skills)
How to use this skill (for a coding agent)
Initialize CloudBase SDK
- Ask the user for their CloudBase environment ID
- Always use the standard initialization pattern shown below
Choose the right storage method
uploadFile- For uploading files from browser to cloud storagegetTempFileURL- For generating temporary download linksdeleteFile- For deleting files from storagedownloadFile- For downloading files to browser
Handle CORS requirements
- Remind users to add their domain to CloudBase console security domains
- This prevents CORS errors during file operations
Follow file path rules
- Use valid characters:
[0-9a-zA-Z],/,!,-,_,.,,*, Chinese characters - Use
/for folder structure (e.g.,folder/file.jpg)
- Use valid characters:
SDK Initialization
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "your-env-id", // Replace with your CloudBase environment ID
});
Initialization rules:
- Always use synchronous initialization with the pattern above
- Do not lazy-load the SDK with dynamic imports
- Keep a single shared
appinstance across your application
File Upload (uploadFile)
Basic Usage
const result = await app.uploadFile({
cloudPath: "folder/filename.jpg", // File path in cloud storage
filePath: fileInput.files[0], // HTML file input element
});
// Result contains:
{
fileID: "cloud://env-id/folder/filename.jpg", // Unique file identifier
// ... other metadata
}
Advanced Upload with Progress
const result = await app.uploadFile({
cloudPath: "uploads/avatar.jpg",
filePath: selectedFile,
method: "put", // "post" or "put" (default: "put")
onUploadProgress: (progressEvent) => {
const percent = Math.round(
(progressEvent.loaded * 100) / progressEvent.total
);
console.log(`Upload progress: ${percent}%`);
// Update UI progress bar here
}
});
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cloudPath |
string | Yes | Absolute path with filename (e.g., "folder/file.jpg") |
filePath |
File | Yes | HTML file input object |
method |
"post" | "put" | No | Upload method (default: "put") |
onUploadProgress |
function | No | Progress callback function |
Cloud Path Rules
- Valid characters:
[0-9a-zA-Z],/,!,-,_,.,,*, Chinese characters - Invalid characters: Other special characters
- Structure: Use
/to create folder hierarchy - Examples:
"avatar.jpg""uploads/avatar.jpg""user/123/avatar.jpg"
CORS Configuration
⚠️ IMPORTANT: To prevent CORS errors, add your domain to CloudBase console:
- Go to CloudBase Console → Environment → Security Sources → Security Domains
- Add your frontend domain (e.g.,
https://your-app.com,http://localhost:3000) - If CORS errors occur, remove and re-add the domain
Temporary Download URLs (getTempFileURL)
Basic Usage
const result = await app.getTempFileURL({
fileList: [
{
fileID: "cloud://env-id/folder/filename.jpg",
maxAge: 3600 // URL valid for 1 hour (seconds)
}
]
});
// Access the download URL
result.fileList.forEach(file => {
if (file.code === "SUCCESS") {
console.log("Download URL:", file.tempFileURL);
// Use this URL to download or display the file
}
});
Multiple Files
const result = await app.getTempFileURL({
fileList: [
{
fileID: "cloud://env-id/image1.jpg",
maxAge: 7200 // 2 hours
},
{
fileID: "cloud://env-id/document.pdf",
maxAge: 86400 // 24 hours
}
]
});
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fileList |
Array | Yes | Array of file objects |
fileList Item Structure
| Parameter | Type | Required | Description |
|---|---|---|---|
fileID |
string | Yes | Cloud storage file ID |
maxAge |
number | Yes | URL validity period in seconds |
Response Structure
{
code: "SUCCESS",
fileList: [
{
code: "SUCCESS",
fileID: "cloud://env-id/folder/file
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cloud-storage-web?
Complete guide for CloudBase cloud storage using Web SDK (@cloudbase/js-sdk) - upload, download, temporary URLs, file management, and best practices.
Как установить скилл cloud-storage-web?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cloud-storage-web запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…