refactor(server): 使用 multipart File 替代报告 ZIP 的 base64 上传

This commit is contained in:
2026-03-05 16:32:41 +08:00
parent 509860bba8
commit 58d57fa148
2 changed files with 5 additions and 4 deletions

View File

@@ -55,7 +55,7 @@ export const signAndPackReport = oc
enterpriseId: z.string().min(1),
inspectionId: z.string().min(1),
summary: z.string().min(1),
rawZipBase64: z.string().min(1),
rawZip: z.file().mime(['application/zip', 'application/x-zip-compressed']),
}),
)
.output(

View File

@@ -222,11 +222,12 @@ export const encryptSummary = os.crypto.encryptSummary.use(db).handler(async ({
export const signAndPackReport = os.crypto.signAndPackReport.use(db).handler(async ({ context, input }) => {
const device = await getDevice(context, input.deviceId)
const rawZipBytes = Buffer.from(input.rawZipBase64, 'base64')
const rawZipArrayBuffer = await input.rawZip.arrayBuffer()
const rawZipBytes = Buffer.from(rawZipArrayBuffer)
if (rawZipBytes.byteLength === 0 || rawZipBytes.byteLength > MAX_RAW_ZIP_BYTES) {
throw new ORPCError('BAD_REQUEST', {
message: 'rawZipBase64 is empty or exceeds max size limit',
message: 'rawZip is empty or exceeds max size limit',
})
}
@@ -234,7 +235,7 @@ export const signAndPackReport = os.crypto.signAndPackReport.use(db).handler(asy
checkCRC32: true,
}).catch(() => {
throw new ORPCError('BAD_REQUEST', {
message: 'rawZipBase64 is not a valid zip file',
message: 'rawZip is not a valid zip file',
})
})