MCPcopy Index your code
hub / github.com/replicate/scribble-diffusion / uploadFile

Function uploadFile

lib/upload.js:7–30  ·  view source on GitHub ↗
(scribbleDataURI)

Source from the content-addressed store, hash-verified

5const UPLOAD_IO_PUBLIC_API_KEY = "public_FW25b4FAzSgqxpyPhtmMePN3hSFg";
6
7export 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}

Callers 1

handleSubmitFunction · 0.85

Calls 1

dataUriToBufferFunction · 0.85

Tested by

no test coverage detected