refactor(server): 使用 multipart File 替代报告 ZIP 的 base64 上传
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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',
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user