docs: plan relative upload storage
parent
8a1525c67c
commit
c956d06d49
@ -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.
|
||||
Loading…
Reference in New Issue