(scribbleDataURI)
| 5 | const UPLOAD_IO_PUBLIC_API_KEY = "public_FW25b4FAzSgqxpyPhtmMePN3hSFg"; |
| 6 | |
| 7 | export default async function uploadFile(scribbleDataURI) { |
| 8 | const uploadManager = new Upload.UploadManager( |
| 9 | new Upload.Configuration({ |
| 10 | apiKey: UPLOAD_IO_PUBLIC_API_KEY, |
| 11 | }) |
| 12 | ); |
| 13 | |
| 14 | const { fileUrl } = await uploadManager.upload({ |
| 15 | accountId: UPLOAD_IO_ACCOUNT_ID, |
| 16 | data: dataUriToBuffer(scribbleDataURI), |
| 17 | mime: "image/png", |
| 18 | originalFileName: "scribble_input.png", |
| 19 | path: { |
| 20 | // See path variables: https://www.bytescale.com/docs/path-variables |
| 21 | folderPath: `/uploads/${packageData.name}/${packageData.version}/{UTC_DATE}`, |
| 22 | fileName: "{ORIGINAL_FILE_NAME}_{UNIQUE_DIGITS_8}{ORIGINAL_FILE_EXT}", |
| 23 | }, |
| 24 | metadata: { |
| 25 | userAgent: navigator.userAgent, |
| 26 | }, |
| 27 | }); |
| 28 | |
| 29 | return fileUrl; |
| 30 | } |
no test coverage detected