From c956d06d498534ca432fc58e62aa949363ca6c58 Mon Sep 17 00:00:00 2001 From: chenyuan Date: Mon, 3 Aug 2026 17:20:32 +0800 Subject: [PATCH] docs: plan relative upload storage --- .../2026-08-03-relative-upload-storage.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 docs/superpowers/plans/2026-08-03-relative-upload-storage.md diff --git a/docs/superpowers/plans/2026-08-03-relative-upload-storage.md b/docs/superpowers/plans/2026-08-03-relative-upload-storage.md new file mode 100644 index 0000000..649dd5d --- /dev/null +++ b/docs/superpowers/plans/2026-08-03-relative-upload-storage.md @@ -0,0 +1,41 @@ +# Relative Upload Storage Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Store new uploads under a relative `file/年/月/日` directory beside the running JAR and persist `file/...` paths. + +**Architecture:** Resolve `file.path: file` against the Java working directory, create it during file utility initialization, and keep the resource handler rooted there. Normalize both new `file/...` and legacy `/年/月/日/...` records before file-system access and public URL creation. + +**Tech Stack:** Spring Boot 2.7, Java, JUnit 5, Windows deployment script. + +## Global Constraints + +- Do not hard-code a drive or server-specific path. +- New database paths must start with `file/`; existing date-only paths must remain readable. +- The public URL must contain exactly one `/file/` segment. + +--- + +### Task 1: Relative local storage and compatibility + +**Files:** +- Modify: `src/main/resources/application-dev.yml` +- Modify: `src/main/java/com/sztzjy/linkCommerce/util/file/LocalFileUtil.java` +- Modify: `src/main/java/com/sztzjy/linkCommerce/config/security/WebConfigurerAdapter.java` +- Modify: upload URL call sites that concatenate `file.url` and stored paths +- Test: `src/test/java/com/sztzjy/linkCommerce/util/file/LocalFileUtilTest.java` + +- [ ] Write a failing test that constructs `LocalFileUtil("file")` in a temporary working directory and expects the `file` root plus `file/2026/8/3/example.pdf` logical path. +- [ ] Implement relative-root resolution, root creation, date-directory creation, and normalization for new and legacy paths. +- [ ] Update the resource mapping and public URL construction so a stored `file/2026/8/3/example.pdf` is served as `/file/2026/8/3/example.pdf`. +- [ ] Run the focused test, then the complete Maven test suite and package build. +- [ ] Commit the implementation. + +### Task 2: Server release verification + +**Files:** +- Deploy: packaged backend release + +- [ ] Publish the verified backend through the existing SSH deployment script. +- [ ] Confirm the JAR-adjacent `file` directory is created on the server and the backend starts successfully. +- [ ] Upload a test file and verify its disk path, returned URL, and persisted `file/...` path.