image icon indicating copy to clipboard operation
image copied to clipboard

imageUploader

Open atlas700 opened this issue 2 years ago • 4 comments

An error occured when running the middleware for the imageUploader route

The error above is from uploadthing using in imageTool in Editor/js

Image Tool: uploading failed because of Error: An error occured when running the middleware for the imageUploader route at UploadThingError.fromResponse (webpack-internal:///(app-pages-browser)/./node_modules/@uploadthing/shared/dist/index.mjs:224:12) at async eval (webpack-internal:///(app-pages-browser)/./node_modules/uploadthing/dist/client.mjs:50:21) at async DANGEROUS__uploadFiles (webpack-internal:///(app-pages-browser)/./node_modules/uploadthing/dist/client.mjs:36:27) at async Object.uploadByFile (webpack-internal:///(app-pages-browser)/./src/components/Editor.tsx:115:49)

atlas700 avatar Aug 04 '23 16:08 atlas700

this is my image tool config in Editor js


 image: {
            class: ImageTool,
            config: {
              uploader: {
                async uploadByFile(file: File) {
                  console.log("uploading");

                  // upload to uploadthing
                  const res = await uploadFiles({
                    files: [file],
                    endpoint: "imageUploader",
                  });
                  return {
                    success: 1,
                    file: { url: res[0].fileUrl },
                  };
                },
              },
            },
          },

atlas700 avatar Aug 04 '23 16:08 atlas700

please help me with that it really hurts!

atlas700 avatar Aug 04 '23 16:08 atlas700

uploadByFile is a key with your function as its value.

try this:

image: {
...
  uploader: {
    uploadByFile: async (file: File) => {...}
  }
...
}

xanderjakeq avatar Aug 07 '23 04:08 xanderjakeq

@xanderjakeq thanks mate! it worked.

atlas700 avatar Aug 15 '23 11:08 atlas700