Agent skill

Fastapi Upload Module Skill

by jiushiwon in jiushiwon/wg-skills

FastAPI 文件上传模块技能。面向已有 FastAPI 项目,提供文件上传、本地存储、OSS 存储、图片处理、附件管理等能力的快速集成。触发词:"文件上传模块"、"上传模块"、"OSS 集成"、"附件管理"、"upload module"、"文件存储"。

Apache-2.0Auto-check passedBackend & APIs

Install Fastapi Upload Module Skill

skills CLI
$ npx skills add jiushiwon/wg-skills --skill fastapi-upload-module-skill -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jiushiwon/wg-skills fastapi-upload-module-skill --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jiushiwon/wg-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/vibeCoding/backend/python/fastapi-module/fastapi-upload-module-skill .claude/skills/fastapi-upload-module-skill && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
fastapi-upload-module-skill
GitHub stars
110
Token cost
~1.7k tokens
SKILL.md length
55 words
Files
3
Skills in repo
121
Repo updated
First seen
Licence
Apache-2.0

At a glance

FastAPI 文件上传模块技能。面向已有 FastAPI 项目,提供文件上传、本地存储、OSS 存储、图片处理、附件管理等能力的快速集成。触发词:"文件上传模块"、"上传模块"、"OSS 集成"、"附件管理"、"upload module"、"文件存储"。

  • Tasks that involve Backend development
  • SKILL.md covers 能力清单, 触发场景, 配置 and 存储服务, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Fastapi Upload Module Skill is an agent skill from jiushiwon/wg-skills. FastAPI 文件上传模块技能。面向已有 FastAPI 项目,提供文件上传、本地存储、OSS 存储、图片处理、附件管理等能力的快速集成。触发词:"文件上传模块"、"上传模块"、"OSS 集成"、"附件管理"、"upload module"、"文件存储"。

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `README.md` and `api-contract-upload.md`).

It sits in Backend & APIs, covering Backend development. It works with FastAPI. The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Backend development

Example prompts

  • “文件上传模块”
  • “OSS 集成”
  • “upload module”
  • “/fastapi-upload-module-skill”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit a4a640b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Fastapi Upload Module Skill loads about 1.7k tokens when it runs. Until then it costs about 39 tokens; SKILL.md has 55 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~39
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jiushiwon/wg-skills at commit a4a640b, republished under its Apache-2.0 licence (© jiushiwon). 55 words, ~1,651 tokens.

Download SKILL.mdSave it as .claude/skills/fastapi-upload-module-skill/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
fastapi-upload-module-skill
description
FastAPI 文件上传模块技能。面向已有 FastAPI 项目,提供文件上传、本地存储、OSS 存储、图片处理、附件管理等能力的快速集成。触发词:"文件上传模块"、"上传模块"、"OSS 集成"、"附件管理"、"upload module"、"文件存储"。

FastAPI Upload Module Skill

面向已有 FastAPI 项目的开发者,快速集成文件上传和存储能力。

能力清单

能力说明
文件上传单文件、多文件、分片上传
本地存储本地磁盘存储
OSS 存储阿里云 OSS、腾讯云 COS
图片处理缩略图、水印、格式转换
附件管理附件 CRUD、分类

触发场景

用户说"帮我加文件上传"或"集成 OSS"时触发。

配置

python
from pydantic_settings import BaseSettings
from typing import Literal

class UploadSettings(BaseSettings):
    # 存储方式: local / aliyun / tencent
    storage_type: Literal["local", "aliyun", "tencent"] = "local"
    
    # 本地存储配置
    local_upload_path: str = "./uploads"
    local_domain: str = "http://localhost:8000"
    
    # 阿里云 OSS 配置
    aliyun_access_key: str = ""
    aliyun_secret_key: str = ""
    aliyun_bucket: str = ""
    aliyun_endpoint: str = "oss-cn-hangzhou.aliyuncs.com"
    
    # 腾讯云 COS 配置
    tencent_secret_id: str = ""
    tencent_secret_key: str = ""
    tencent_bucket: str = ""
    tencent_region: str = "ap-guangzhou"
    
    # 允许的文件类型
    allowed_types: list[str] = ["jpg", "jpeg", "png", "gif", "pdf", "doc", "docx", "xls", "xlsx", "zip"]
    max_file_size: int = 10 * 1024 * 1024  # 10MB

存储服务

本地存储
python
import os
import uuid
from pathlib import Path

class LocalStorage:
    def __init__(self, settings: UploadSettings):
        self.base_path = Path(settings.local_upload_path)
        self.base_path.mkdir(parents=True, exist_ok=True)
    
    async def upload(self, file: UploadFile) -> str:
        # 生成唯一文件名
        ext = file.filename.split(".")[-1]
        filename = f"{uuid.uuid4()}.{ext}"
        
        # 按日期分目录
        date_path = datetime.now().strftime("%Y/%m/%d")
        save_dir = self.base_path / date_path
        save_dir.mkdir(parents=True, exist_ok=True)
        
        # 保存文件
        file_path = save_dir / filename
        content = await file.read()
        file_path.write_bytes(content)
        
        # 返回访问 URL
        return f"{settings.local_domain}/uploads/{date_path}/{filename}"
    
    async def delete(self, url: str) -> bool:
        # 从 URL 提取路径并删除
        path = url.replace(settings.local_domain, "")
        file_path = self.base_path / path.lstrip("/")
        if file_path.exists():
            file_path.unlink()
            return True
        return False
阿里云 OSS
python
import oss2

class AliyunStorage:
    def __init__(self, settings: UploadSettings):
        auth = oss2.Auth(settings.aliyun_access_key, settings.aliyun_secret_key)
        self.bucket = oss2.Bucket(auth, settings.aliyun_endpoint, settings.aliyun_bucket)
    
    async def upload(self, file: UploadFile) -> str:
        ext = file.filename.split(".")[-1]
        filename = f"{uuid.uuid4()}.{ext}"
        date_path = datetime.now().strftime("%Y/%m/%d")
        key = f"uploads/{date_path}/{filename}"
        
        content = await file.read()
        self.bucket.put_object(key, content)
        
        return f"https://{self.bucket.bucket_name}.{self.aliyun_endpoint}/{key}"
    
    async def delete(self, url: str) -> bool:
        key = url.split(f"https://{self.bucket.bucket_name}.")[-1]
        self.bucket.delete_object(key)
        return True

上传接口

python
from fastapi import UploadFile, File, Form
from dataclasses import dataclass

@dataclass
class UploadResult:
    url: str
    filename: str
    size: int
    content_type: str

@router.post("/upload/single")
async def upload_single(file: UploadFile = File(...)):
    """单文件上传"""
    # 验证文件类型
    ext = file.filename.split(".")[-1].lower()
    if ext not in settings.allowed_types:
        raise BusinessException(ErrorCode.FILE_TYPE_NOT_ALLOWED)
    
    # 验证文件大小
    content = await file.read()
    if len(content) > settings.max_file_size:
        raise BusinessException(ErrorCode.FILE_TOO_LARGE)
    
    # 上传
    url = await storage.upload(file)
    
    return Success(data=UploadResult(
        url=url,
        filename=file.filename,
        size=len(content),
        content_type=file.content_type
    ))

@router.post("/upload/multiple")
async def upload_multiple(files: list[UploadFile] = File(...)):
    """多文件上传"""
    results = []
    for file in files:
        url = await storage.upload(file)
        results.append(UploadResult(
            url=url,
            filename=file.filename,
            size=0,
            content_type=file.content_type
        ))
    return Success(data=results)

图片处理

python
from PIL import Image
import io

class ImageProcessor:
    @staticmethod
    async def thumbnail(image_bytes: bytes, size: tuple[int, int] = (200, 200)) -> bytes:
        """生成缩略图"""
        img = Image.open(io.BytesIO(image_bytes))
        img.thumbnail(size, Image.LANCZOS)
        output = io.BytesIO()
        img.save(output, format=img.format or 'JPEG')
        return output.getvalue()
    
    @staticmethod
    async def watermark(image_bytes: bytes, text: str) -> bytes:
        """添加水印"""
        img = Image.open(io.BytesIO(image_bytes))
        draw = ImageDraw.Draw(img)
        
        # 添加文字水印
        draw.text((10, 10), text, fill=(255, 255, 255, 128))
        
        output = io.BytesIO()
        img.save(output, format=img.format or 'JPEG')
        return output.getvalue()
    
    @staticmethod
    async def compress(image_bytes: bytes, quality: int = 85) -> bytes:
        """压缩图片"""
        img = Image.open(io.BytesIO(image_bytes))
        output = io.BytesIO()
        img.save(output, format='JPEG', quality=quality, optimize=True)
        return output.getvalue()

附件管理

附件表
python
class Attachment(Base):
    __tablename__ = "wg_attachment"
    
    id = Column(BigInteger, primary_key=True, autoincrement=True)
    filename = Column(String(255), nullable=False)  # 原文件名
    file_path = Column(String(500), nullable=False)  # 存储路径
    file_url = Column(String(500), nullable=False)  # 访问 URL
    file_size = Column(BigInteger)  # 文件大小
    content_type = Column(String(100))  # MIME 类型
    file_ext = Column(String(20))  # 扩展名
    category = Column(String(50))  # 分类:avatar/article/attachment
    uploader_id = Column(BigInteger)  # 上传人
    created_at = Column(DateTime, server_default=func.now())
    deleted_at = Column(DateTime)
附件接口
方法路径说明
GET/api/attachment/list附件列表
GET/api/attachment/{id}附件详情
DELETE/api/attachment/{id}删除附件

不做

  • 不提供文件预览服务(需自行搭建)
  • 不处理版权和合规审查
  • 不提供 CDN 加速(需自行配置)

© jiushiwon, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files in vibeCoding/backend/python/fastapi-module/fastapi-upload-module-skill of jiushiwon/wg-skills.

  • SKILL.md
  • README.md
  • api-contract-upload.md

Open the folder on GitHubat commit a4a640b

Compare with similar skills

Fastapi Upload Module Skill next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Fastapi Upload Module Skill compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Fastapi Upload Module Skill this skilljiushiwon/wg-skills110—~1.7kAutomated safety check: PassApache-2.0
Fastcrudbenavlabs/fastcrud1.6k—~5kAutomated safety check: PassMIT
FastapiOpen-TutorAi/open-tutor-ai-CE1082 repos~2.6kAutomated safety check: PassBSD-3-Clause
API Surface Reviewpolarsource/polar10k—~1.3kAutomated safety check: PassMIT
FastAPI-Redis SDK Developmentredis/fastapi-redis-sdk404—~2.5kAutomated safety check: NotesMIT
Phoenix ServerArize-ai/phoenix12k—~1.6kAutomated safety check: PassCustom licence

Similar skills

  • Fastcrud

    benavlabs/fastcrud

    A skill your agent uses when building or modifying CRUD endpoints with FastCRUD (the fastcrud PyPI package) in a FastAPI project — covers FastCRUD, crudrouter, EndpointCreator, FilterConfig…

    1.6k GitHub stars~5k tokensUpdated 12 days ago
    Backend & APIsAuto-check passed
  • Fastapi

    Open-TutorAi/open-tutor-ai-CE

    FastAPI best practices and conventions. An agent skill from Open-TutorAi/open-tutor-ai-CE.

    108 GitHub starsUsed in 2 repos~2.6k tokens
    Backend & APIsAuto-check passed
  • API Surface Review

    polarsource/polar

    Review changes to Polar's API contract — Pydantic schemas, FastAPI endpoints, OpenAPI output and the generated SDKs.

    10k GitHub stars~1.3k tokensUpdated today
    Backend & APIsAuto-check passed
  • FastAPI-Redis SDK Development

    redis/fastapi-redis-sdk

    Official

    Guides development on the fastapi-redis-sdk library itself - its connection lifecycle, dependency-injected caching, and async/sync bridging.

    404 GitHub stars~2.5k tokensUpdated 6 days ago
    Backend & APIsAuto-check: notes
  • Phoenix Server

    Arize-ai/phoenix

    Backend development guide for the Phoenix AI observability platform (Strawberry GraphQL, SQLAlchemy async, FastAPI).

    12k GitHub stars~1.6k tokensUpdated today
    Backend & APIsAuto-check passed
  • Andrej Karpathy Perspective

    nazarli-shabnam/clevis

    Andrej Karpathy的思维框架与表达方式。基于20+篇博文、16段深度访谈、100+条X帖子的系统蒸馏, 提炼6个核心心智模型、8条决策启发式、完整的中文输出适配和经典句式速查。

    170 GitHub starsUsed in 3 repos~3.8k tokens
    Backend & APIsAuto-check passed

More from jiushiwon/wg-skills

All 121 skills in this repo
  • Frontend UI Foundry

    jiushiwon/wg-skills

    A skill your agent uses when generating UI for a specific scenario (mobile/PC/官网/管理端/营销页/文档/金融/原生/3D), when refactoring an existing HTML/Vue/React project to a unified design system, when extracting…

    110 GitHub stars~1.4k tokensUpdated 3 days ago
    Auto-check passed
  • Workflow Diagram Skill

    jiushiwon/wg-skills

    A skill your agent uses when 用户想用一句话生成流程图、工作流图解、开发流程图、AI 流程图或任何步骤型图解,支持多风格输出(flat icon / 暖白手账风 / dark / cute),并提供现成模板一键出图。

    110 GitHub stars~1.2k tokensUpdated 3 days ago
    Auto-check passed
  • Uniapp App Generate Skill

    jiushiwon/wg-skills

    This skill should be used when the user wants to create a standardized uni-app project for WeChat mini-program, H5, and App from scratch.

    110 GitHub stars~5k tokensUpdated 3 days ago
    Auto-check: notes
  • Fastapi Init Skill

    jiushiwon/wg-skills

    FastAPI 项目一键初始化技能。面向零基础小白,提供环境探测、自动安装、完整 Web 骨架生成、SSE 流式框架、JWT 鉴权、统一响应封装、文件上传接口、一键启动/重启脚本、Swagger 文档,内置 MySQL(默认)/ PostgreSQL / MongoDB 数据库选择。用户只需说"帮我搭一个 FastAPI 项目"即可一条命令完成从零到跑的完整链路。触发词:"FastAPI…

    110 GitHub stars~1.8k tokensUpdated 3 days ago
    Auto-check: notes
  • Ffmpeg Skill

    jiushiwon/wg-skills

    FFmpeg 多媒体处理技能 — 将自然语言描述转为正确的 ffmpeg 命令,覆盖视频剪辑、转码、水印、合成、提取、生成等操作。内置一键安装脚本(Windows/Mac/Linux)。触发词:ffmpeg、视频剪辑、视频裁剪、视频转码、视频压缩、去水印、加水印、视频拼接、视频合成、提取音频、视频转…

    110 GitHub stars~1.4k tokensUpdated 3 days ago
    Auto-check passed
  • Frontend Request Skill

    jiushiwon/wg-skills

    A skill your agent uses when designing or reviewing the request layer of a frontend project (web / uni-app / mini-program), including request.ts wrappers, interceptors, deduplication, mocks, error…

    110 GitHub stars~3.6k tokensUpdated 3 days ago
    Auto-check passed

Works with

Categories

Questions about Fastapi Upload Module Skill

What does Fastapi Upload Module Skill do?

FastAPI 文件上传模块技能。面向已有 FastAPI 项目,提供文件上传、本地存储、OSS 存储、图片处理、附件管理等能力的快速集成。触发词:"文件上传模块"、"上传模块"、"OSS 集成"、"附件管理"、"upload module"、"文件存储"。. Fastapi Upload Module Skill is an agent skill from jiushiwon/wg-skills.

When should I use Fastapi Upload Module Skill?

Fastapi Upload Module Skill fits situations like: tasks that involve Backend development.

How do I install Fastapi Upload Module Skill in Claude Code?

Run `npx skills add jiushiwon/wg-skills --skill fastapi-upload-module-skill -a claude-code`. Or copy the skill folder (vibeCoding/backend/python/fastapi-module/fastapi-upload-module-skill in jiushiwon/wg-skills) into .claude/skills/fastapi-upload-module-skill in your project. Claude Code loads it when a task matches its description.

How do I install Fastapi Upload Module Skill in Codex?

Run `npx skills add jiushiwon/wg-skills --skill fastapi-upload-module-skill -a codex`. Or copy the skill folder (vibeCoding/backend/python/fastapi-module/fastapi-upload-module-skill in jiushiwon/wg-skills) into .agents/skills/fastapi-upload-module-skill in your project. Codex loads it when a task matches its description.

Can I use Fastapi Upload Module Skill in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jiushiwon/wg-skills --skill fastapi-upload-module-skill -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/fastapi-upload-module-skill, .gemini/skills/fastapi-upload-module-skill, .github/skills/fastapi-upload-module-skill and .opencode/skills/fastapi-upload-module-skill in your project.

What does Fastapi Upload Module Skill need to run?

SKILL.md names no scripts, command-line tools or credentials: Fastapi Upload Module Skill is instructions for the agent only. Our summary lists: Python 3.

Does Fastapi Upload Module Skill access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Fastapi Upload Module Skill safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Fastapi Upload Module Skill use?

Fastapi Upload Module Skill is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Fastapi Upload Module Skill use?

About 1.7k tokens (SKILL.md is roughly 6.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Fastapi Upload Module Skill?

Skills that share tags, products or a category with Fastapi Upload Module Skill: Fastcrud (benavlabs/fastcrud, 1.6k stars), Fastapi (Open-TutorAi/open-tutor-ai-CE, 108 stars), API Surface Review (polarsource/polar, 10k stars) and FastAPI-Redis SDK Development (redis/fastapi-redis-sdk, 404 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Fastapi Upload Module Skill?

jiushiwon (a GitHub user) maintains it in jiushiwon/wg-skills, which has 110 GitHub stars. The repository holds 121 skills in this directory. The repository was last updated on October 4, 2026.

Source: jiushiwon/wg-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.