Logo: Springboot Upload Module Skill

Springboot Upload Module Skill

Communautéit
jiushiwon
springboot-upload-module-skill

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

Iwwersiicht

Editeurjiushiwon
Repositorywg-skills
Skill-Nummspringboot-upload-module-skill
Stären
123
Forks
38
Matgeliwwert Dateien
1
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 1 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    jiushiwon huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Springboot Upload Module Skill an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/java/springboot-module/springboot-upload-module-skill
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

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
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Springboot Upload Module Skill an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Springboot Upload Module Skill automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Springboot Upload Module Skill net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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 加速(需自行配置)

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Springboot Upload Module Skill?

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

Firwat Springboot Upload Module Skill op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Springboot Upload Module Skill besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Springboot Upload Module Skill an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/java/springboot-module/springboot-upload-module-skill an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Springboot Upload Module Skill benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Springboot Upload Module Skill benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Springboot Upload Module Skill domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Springboot Upload Module Skill gratis?

Jo. jiushiwon huet de Skill ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇