Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imageUploader #223

Open
atlas700 opened this issue Aug 4, 2023 · 4 comments
Open

imageUploader #223

atlas700 opened this issue Aug 4, 2023 · 4 comments

Comments

@atlas700
Copy link

atlas700 commented Aug 4, 2023

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
Copy link
Author

atlas700 commented Aug 4, 2023

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
Copy link
Author

atlas700 commented Aug 4, 2023

please help me with that it really hurts!

@xanderjakeq
Copy link

uploadByFile is a key with your function as its value.

try this:

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

@atlas700
Copy link
Author

@xanderjakeq
thanks mate! it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants