(file: File, type: UploadEnum = 'attachments')
| 22 | |
| 23 | export default class UploadService { |
| 24 | static async upload(file: File, type: UploadEnum = 'attachments') { |
| 25 | const folder = mapFolder[type]; |
| 26 | if (!folder) { |
| 27 | throw new Error('invalid option'); |
| 28 | } |
| 29 | const path = [folder, v4(), file.name || 'unknown'].join('/'); |
| 30 | await uploadFile({ Key: path, Body: file.buffer }); |
| 31 | return { |
| 32 | id: file.id, |
| 33 | url: [LINEN_STATIC_CDN, path].join('/'), |
| 34 | }; |
| 35 | } |
| 36 | } |
nothing calls this directly
no test coverage detected