Springboot Upload Module Skillのロゴ

Springboot Upload Module Skill

コミュニティ
jiushiwon
springboot-upload-module-skill

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

概要

公開者jiushiwon
リポジトリwg-skills
スキル名springboot-upload-module-skill
スター
123
フォーク
38
同梱ファイル
1
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 1個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    jiushiwonがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Springboot Upload Module Skill」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/java/springboot-module/springboot-upload-module-skill
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jiushiwon/wg-skills.git /tmp/wg-skills
mkdir -p .claude/skills
cp -r /tmp/wg-skills/vibeCoding/backend/java/springboot-module/springboot-upload-module-skill .claude/skills/springboot-upload-module-skill
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでSpringboot Upload Module Skillを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にSpringboot Upload Module Skillを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Springboot Upload Module Skillは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Spring Boot Upload Module Skill

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

能力清单

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

触发场景

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

配置

yaml
# application.yml
upload:
  # 存储方式: local / aliyun / tencent
  storage-type: local
  
  # 本地存储
  local:
    path: ./uploads
    domain: http://localhost:8080
  
  # 阿里云 OSS
  aliyun:
    access-key: ${ALIYUN_ACCESS_KEY:}
    secret-key: ${ALIYUN_SECRET_KEY:}
    bucket: ${ALIYUN_BUCKET:}
    endpoint: oss-cn-hangzhou.aliyuncs.com
  
  # 腾讯云 COS
  tencent:
    secret-id: ${TENCENT_SECRET_ID:}
    secret-key: ${TENCENT_SECRET_KEY:}
    bucket: ${TENCENT_BUCKET:}
    region: ap-guangzhou
  
  # 文件限制
  allowed-types: jpg,jpeg,png,gif,pdf,doc,docx,xls,xlsx,zip
  max-size: 10485760  # 10MB
java
@Data
@ConfigurationProperties(prefix = "upload")
public class UploadProperties {
    private String storageType = "local";
    private Local local = new Local();
    private Aliyun aliyun = new Aliyun();
    private Tencent tencent = new Tencent();
    private List<String> allowedTypes;
    private long maxSize;
    
    @Data
    public static class Local {
        private String path = "./uploads";
        private String domain = "http://localhost:8080";
    }
    
    @Data
    public static class Aliyun {
        private String accessKey;
        private String secretKey;
        private String bucket;
        private String endpoint;
    }
    
    @Data
    public static class Tencent {
        private String secretId;
        private String secretKey;
        private String bucket;
        private String region;
    }
}

存储服务

本地存储

java
@Service
public class LocalStorageService {
    
    @Value("${upload.local.path}")
    private String basePath;
    
    @Value("${upload.local.domain}")
    private String domain;
    
    public String upload(MultipartFile file) throws IOException {
        // 生成唯一文件名
        String originalFilename = file.getOriginalFilename();
        String ext = getExt(originalFilename);
        String filename = UUID.randomUUID().toString() + "." + ext;
        
        // 按日期分目录
        String datePath = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd"));
        Path saveDir = Paths.get(basePath, datePath);
        Files.createDirectories(saveDir);
        
        // 保存文件
        Path filePath = saveDir.resolve(filename);
        file.transferTo(filePath.toFile());
        
        // 返回访问 URL
        return domain + "/uploads/" + datePath + "/" + filename;
    }
    
    public boolean delete(String url) {
        try {
            String path = url.replace(domain, "");
            Path filePath = Paths.get(basePath, path);
            return Files.deleteIfExists(filePath);
        } catch (IOException e) {
            return false;
        }
    }
}

阿里云 OSS

java
@Service
public class AliyunStorageService {
    
    @Autowired
    private UploadProperties properties;
    
    private OSS getClient() {
        OSSAuth auth = new OSSAuth(properties.getAliyun().getAccessKey(), 
                                   properties.getAliyun().getSecretKey());
        return new OSSClientBuilder().build(auth, 
            properties.getAliyun().getEndpoint());
    }
    
    public String upload(MultipartFile file) throws IOException {
        OSS client = getClient();
        String ext = getExt(file.getOriginalFilename());
        String filename = UUID.randomUUID().toString() + "." + ext;
        String datePath = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd"));
        String key = "uploads/" + datePath + "/" + filename;
        
        client.putObject(properties.getAliyun().getBucket(), key, file.getInputStream());
        
        return "https://" + properties.getAliyun().getBucket() + "." + 
               properties.getAliyun().getEndpoint() + "/" + key;
    }
}

上传接口

java
@RestController
@RequestMapping("/api/upload")
@RequiredArgsConstructor
public class UploadController {
    
    private final StorageService storageService;
    
    @PostMapping("/single")
    public Result<UploadResult> uploadSingle(@RequestParam("file") MultipartFile file) {
        // 验证文件
        validateFile(file);
        
        try {
            String url = storageService.upload(file);
            return Result.success(UploadResult.builder()
                .url(url)
                .filename(file.getOriginalFilename())
                .size(file.getSize())
                .contentType(file.getContentType())
                .build());
        } catch (IOException e) {
            throw new BusinessException("文件上传失败");
        }
    }
    
    @PostMapping("/multiple")
    public Result<List<UploadResult>> uploadMultiple(@RequestParam("files") MultipartFile[] files) {
        List<UploadResult> results = new ArrayList<>();
        for (MultipartFile file : files) {
            validateFile(file);
            try {
                String url = storageService.upload(file);
                results.add(UploadResult.builder()
                    .url(url)
                    .filename(file.getOriginalFilename())
                    .size(file.getSize())
                    .contentType(file.getContentType())
                    .build());
            } catch (IOException e) {
                log.error("文件上传失败: {}", file.getOriginalFilename(), e);
            }
        }
        return Result.success(results);
    }
    
    private void validateFile(MultipartFile file) {
        if (file.isEmpty()) {
            throw new BusinessException("文件不能为空");
        }
        if (file.getSize() > uploadProperties.getMaxSize()) {
            throw new BusinessException("文件大小超过限制");
        }
        String ext = getExt(file.getOriginalFilename());
        if (!uploadProperties.getAllowedTypes().contains(ext.toLowerCase())) {
            throw new BusinessException("不支持的文件类型");
        }
    }
}

@Data
@Builder
public class UploadResult {
    private String url;
    private String filename;
    private long size;
    private String contentType;
}

图片处理

java
@Service
public class ImageService {
    
    /**
     * 生成缩略图
     */
    public byte[] thumbnail(MultipartFile file, int width, int height) throws IOException {
        BufferedImage image = ImageIO.read(file.getInputStream());
        BufferedImage thumb = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = thumb.createGraphics();
        g.drawImage(image.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null);
        g.dispose();
        
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ImageIO.write(thumb, "JPEG", out);
        return out.toByteArray();
    }
    
    /**
     * 添加水印
     */
    public byte[] watermark(MultipartFile file, String text) throws IOException {
        BufferedImage image = ImageIO.read(file.getInputStream());
        Graphics2D g = image.createGraphics();
        g.setColor(new Color(255, 255, 255, 128));
        g.setFont(new Font("Arial", Font.PLAIN, 20));
        g.drawString(text, 10, image.getHeight() - 10);
        g.dispose();
        
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ImageIO.write(image, "JPEG", out);
        return out.toByteArray();
    }
    
    /**
     * 压缩图片
     */
    public byte[] compress(MultipartFile file, int quality) throws IOException {
        BufferedImage image = ImageIO.read(file.getInputStream());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ImageIO.write(image, "JPEG", out);
        
        // 使用 Thumbnails 或 Caesium 进行压缩
        return out.toByteArray();
    }
}

附件管理

附件实体

java
@Data
@Entity
@Table(name = "wg_attachment")
public class Attachment {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(nullable = false)
    private String filename;
    
    @Column(nullable = false)
    private String filePath;
    
    @Column(nullable = false)
    private String fileUrl;
    
    private Long fileSize;
    
    private String contentType;
    
    private String fileExt;
    
    private String category;  // avatar/article/attachment
    
    private Long uploaderId;
    
    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;
    
    @Column(name = "deleted_at")
    private LocalDateTime deletedAt;
}

附件接口

方法路径说明
GET/api/attachment/list附件列表
GET/api/attachment/{id}附件详情
DELETE/api/attachment/{id}删除附件

不做

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

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Springboot Upload Module Skill」では何ができますか?

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

TypingMindでSpringboot Upload Module Skillを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Springboot Upload Module Skillはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにSpringboot Upload Module Skillをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/java/springboot-module/springboot-upload-module-skillを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Springboot Upload Module Skillを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Springboot Upload Module Skillで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもSpringboot Upload Module Skillを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Springboot Upload Module Skill」は無料ですか?

はい。jiushiwonがApache-2.0ライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇