mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-28 03:44:27 +00:00
feat(upload): S3 multipart upload with offline resume and wake lock (#391)
* feat(upload): implement S3 multipart upload with offline resume and wake lock * fix(upload): harden S3 sign and abort authorization, await confirmation, and clean up failed multipart uploads * fix(webui): resume multipart upload on network recovery and log online event * fix(webui): remove offline and online toast notifications
This commit is contained in:
@@ -36,17 +36,45 @@ export type PresignedUrl = z.infer<typeof presignedUrlSchema>
|
||||
export const createUploadTaskResponseSchema = z.object({
|
||||
taskId: z.string(),
|
||||
presignedUrls: z.array(presignedUrlSchema),
|
||||
storageBackend: z.enum(['s3', 'local']).default('local'),
|
||||
createdAssets: z
|
||||
.array(
|
||||
z.object({
|
||||
tempId: z.string(),
|
||||
assetId: z.string(),
|
||||
key: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
})
|
||||
export type CreateUploadTaskResponse = z.infer<typeof createUploadTaskResponseSchema>
|
||||
|
||||
export const s3SignRequestSchema = z.object({
|
||||
key: z.string().min(1),
|
||||
method: z.enum(['PUT', 'POST', 'GET', 'DELETE']),
|
||||
uploadId: z.string().optional(),
|
||||
partNumber: z.number().int().positive().optional(),
|
||||
fileId: z.string().min(1),
|
||||
})
|
||||
export type S3SignRequest = z.infer<typeof s3SignRequestSchema>
|
||||
|
||||
export const s3SignResponseSchema = z.object({
|
||||
url: z.string(),
|
||||
})
|
||||
export type S3SignResponse = z.infer<typeof s3SignResponseSchema>
|
||||
|
||||
export const abortUploadRequestSchema = z.object({
|
||||
fileId: z.string().min(1),
|
||||
uploadId: z.string().optional(),
|
||||
key: z.string().optional(),
|
||||
})
|
||||
export type AbortUploadRequest = z.infer<typeof abortUploadRequestSchema>
|
||||
|
||||
export const abortUploadResponseSchema = z.object({
|
||||
success: z.boolean(),
|
||||
})
|
||||
export type AbortUploadResponse = z.infer<typeof abortUploadResponseSchema>
|
||||
|
||||
export const confirmFileUploadRequestSchema = z.object({
|
||||
fileId: z.string(),
|
||||
errorMessage: z.string().optional(),
|
||||
|
||||
Reference in New Issue
Block a user