editor-js / image

Image Block for Editor.js
MIT License
234 stars 282 forks source link

imageUploader #223

Open atlas700 opened 1 year ago

atlas700 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

please help me with that it really hurts!

xanderjakeq commented 1 year ago

uploadByFile is a key with your function as its value.

try this:

image: {
...
  uploader: {
    uploadByFile: async (file: File) => {...}
  }
...
}
atlas700 commented 1 year ago

@xanderjakeq thanks mate! it worked.