( key: string, config: S3Config, contentType: string, purpose: string )
| 206 | } |
| 207 | |
| 208 | async function createS3Backend( |
| 209 | key: string, |
| 210 | config: S3Config, |
| 211 | contentType: string, |
| 212 | purpose: string |
| 213 | ): Promise<MultipartBackend> { |
| 214 | const { |
| 215 | initiateS3MultipartUpload, |
| 216 | uploadS3Part, |
| 217 | completeS3MultipartUpload, |
| 218 | abortS3MultipartUpload, |
| 219 | } = await import('@/lib/uploads/providers/s3/client') |
| 220 | const { uploadId } = await initiateS3MultipartUpload({ |
| 221 | fileName: key, |
| 222 | contentType, |
| 223 | fileSize: 0, |
| 224 | customConfig: config, |
| 225 | customKey: key, |
| 226 | purpose, |
| 227 | }) |
| 228 | const parts: S3MultipartPart[] = [] |
| 229 | return { |
| 230 | async uploadPart(partNumber, body) { |
| 231 | parts.push(await uploadS3Part(key, uploadId, partNumber, body, config)) |
| 232 | }, |
| 233 | finish: () => completeS3MultipartUpload(key, uploadId, parts, config).then(() => undefined), |
| 234 | abort: () => abortS3MultipartUpload(key, uploadId, config), |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | async function createBlobBackend( |
| 239 | key: string, |
no test coverage detected