feat: 接入对象存储图片直传
This commit is contained in:
1 parent
f57c0ca0ea
commit
84956b8fe2
14 files changed
+548
-15
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
test("upload presign DTO rejects unsupported media type and oversized names", async () => {
|
||||
const { PresignUploadDto } = await import("../dist/modules/admin/admin-upload.controller.js");
|
||||
const validator = await import("class-validator");
|
||||
const invalid = new PresignUploadDto();
|
||||
invalid.fileName = "x".repeat(256);
|
||||
invalid.contentType = "application/pdf";
|
||||
const errors = await validator.validate(invalid);
|
||||
assert.ok(errors.some((error) => error.property === "fileName"));
|
||||
assert.ok(errors.some((error) => error.property === "contentType"));
|
||||
|
||||
const valid = new PresignUploadDto();
|
||||
valid.fileName = "hero.jpg";
|
||||
valid.contentType = "image/jpeg";
|
||||
assert.deepEqual(await validator.validate(valid), []);
|
||||
});
|
||||
Reference in new issue
Block a user