Skip to content

Commit e255b66

Browse files
committed
feat: add validation and storage enhancements
1 parent f27f625 commit e255b66

File tree

69 files changed

+3317
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3317
-376
lines changed

.cursorignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
1717
- **Swagger/OpenAPI 3** documentation at `/swagger-ui/index.html`
1818
- **Configuration Profiles** for dev/prod, fully externalized properties
1919
- **Scalability Hooks**: Redis caching ready (see below), async processors, scheduled cleanup jobs
20+
- **Pluggable File Storage**: switch between local disk and AWS S3 with reusable upload services
2021

2122
## Getting Started
2223

@@ -77,6 +78,9 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
7778
| `app.caching.enabled` | Master switch to turn Redis caching on/off |
7879
| `spring.flyway.*` | Migration toggles, locations |
7980
| `spring.data.redis.*` | Redis host/port/password (enable caching) |
81+
| `filestorage.mode` | `local` (default) or `s3` upload backend |
82+
| `filestorage.local.*` | Local base path + public URI prefix (defaults to `uploads/` + `/uploads`) |
83+
| `filestorage.s3.*` | Bucket, region, credentials, optional CDN base URL, root folder |
8084

8185
See `application.properties` for defaults.
8286

@@ -90,8 +94,26 @@ See `application.properties` for defaults.
9094

9195
- `JwtHelperTest` ensures token generation + validation.
9296
- `AccountSecurityServiceImplTest` covers lockout + reset behavior.
97+
- `FileStorageConfigTest` asserts the correct storage backend is wired for each mode.
98+
- `UserControllerTest` verifies the new profile-photo endpoints delegate to the storage service.
9399
- Run suite via `./mvnw test`.
94100

101+
## File Uploads & Profile Photos
102+
103+
- **Local mode (default):** files land under `uploads/` in the project root, exposed via `/uploads/**`. Override the directory URI via `filestorage.local.base-path` and `filestorage.local.public-uri-prefix`.
104+
- **S3 mode:** set `filestorage.mode=s3` and provide `filestorage.s3.bucket-name`, `region`, credentials (`access-key`, `secret-key`) and optional `public-base-url` if you front it with CloudFront/CDN.
105+
- **Cleanup toggle:** `filestorage.cleanup.enabled=true` removes the old file whenever a replacement upload succeeds; turn off to keep old revisions.
106+
- **Multipart sizes:** controlled through `spring.servlet.multipart.max-file-size` / `max-request-size` (defaults to 10 MB but override via env vars).
107+
108+
### Profile photo endpoints
109+
110+
| Endpoint | Description |
111+
| --- | --- |
112+
| `POST /api/v1/users/{id}/profile-photo` | Admin/owner uploads or replaces the specified user's profile photo. Accepts multipart `file` (JPEG, PNG, WEBP, GIF, AVIF, PDF). |
113+
| `POST /api/v1/users/me/profile-photo` | Authenticated user updates their own photo using the same payload. |
114+
115+
Responses return the updated `UserDto` with the resolved `profileImageUrl`. The storage layer exposes simple builder classes (`FileUploadRequest`, `StoredFile`) so future features (attachments, documents, etc.) can reuse the same abstraction without touching controllers.
116+
95117
## Scalability Hooks
96118

97119
- **Redis caching ready** (toggle with `app.caching.enabled` and provide Redis props)

0 commit comments

Comments
 (0)