feat(s3): enhance logging and public URL generation
Some checks failed
Backend Tests / test (push) Successful in 1m11s
Lint / lint (backend) (push) Failing after 46s
Lint / lint (documentation) (push) Successful in 1m7s
Lint / lint (frontend) (push) Has been cancelled

Add detailed logging for S3 uploads in user and content services. Improve public URL generation logic in `S3Service` by providing better handling for `API_URL`, `DOMAIN_NAME`, and `PORT`. Update relevant tests to cover all scenarios.
This commit is contained in:
Mathis HERRIOT
2026-01-15 00:40:36 +01:00
parent f79507730e
commit 8d27532dc0
6 changed files with 50 additions and 42 deletions

View File

@@ -9,13 +9,15 @@ export class MediaController {
@Get("*key")
async getFile(@Param("key") key: string, @Res() res: Response) {
try {
const stats = await this.s3Service.getFileInfo(key);
const stats = (await this.s3Service.getFileInfo(key)) as any;
const stream = await this.s3Service.getFile(key);
res.setHeader(
"Content-Type",
stats.metaData["content-type"] || "application/octet-stream",
);
const contentType =
stats.metaData?.["content-type"] ||
stats.metadata?.["content-type"] ||
"application/octet-stream";
res.setHeader("Content-Type", contentType);
res.setHeader("Content-Length", stats.size);
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");