实现附件上传与下载

Open
#15 0 comments 0 reactions 0 assignees View on GitHub

@linuxsuren-fs is already working on this.

Since Nov 14, 2026.

  • #22 by @linuxsuren-fs — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale

Research direction

Read the designs in issues #2 and #3 and resolve dependency #13 first. Start with the internal/storage interface, then implement local storage and the upload and download endpoints described here. Done means tenant-scoped access, configured size and type checks, SHA-256 storage, timeline association, integration tests, and synchronized OpenAPI; pull request #22 is already open.

Written by the indexing model from the issue text.

Description

help wanted P0

Background

工单附件用于报障截图、现场照片等。设计见 #2(表)、#3(端点)。P0 本地磁盘存储,S3 等对象存储 P2 再接。

Technical requirement

  • POST /api/tickets/:id/attachments:multipart 上传;单文件默认上限 20MB(配置项);类型白名单:png / jpeg / webp / gif / pdf / zip / txt(配置项扩展);
  • 计算并落库 sha256;存储路径 data/uploads/{tenant_id}/{yyyy-MM}/{ulid或雪花id}{ext},文件名不由用户输入决定,杜绝路径穿越;
  • GET /api/attachments/:id/content:鉴权(租户内;requester 仅自己的工单),带 Content-Disposition 与正确的 Content-Type;
  • 与 timeline 关联:上传成功可选携带 timeline_id,或自动追加 system kind 记录;
  • 存储层抽象为接口(internal/storage),本地实现 + 接口测试,便于 P2 增加 S3 实现;
  • 上传与下载均计入租户 scope(跨租户 404)。

Expect

  • 集成测试:超限 / 非白名单类型被拒;跨租户下载 404;路径穿越样例文件名被安全化;
  • OpenAPI 同步。

Potential TODO list

  • storage 接口 + 本地实现
  • 上传端点(校验、sha256、路径生成)
  • 下载端点(鉴权、Disposition)
  • timeline 关联
  • 集成测试

依赖

#13。

Dominant language
No language data
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from LinuxSuRen/tick-flow

All issues in LinuxSuRen/tick-flow

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.