editor-js / editor-js/image

Facing issue in img upload when using uploadthing v4.x.x ++(using 7.3.0)

Open
#277 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
285
Forks
307
PR merge metrics
No merged PRs in 30d

Description

Got Image Tool: uploading failed because of TypeError: Cannot read properties of undefined (reading 'reduce')
when im trying to upload an image.

my img:
```
image: {
class: ImageTool,
config: {
uploader: {
uploadByFile: async (file: File) => {
console.log(file);

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

```

my uploadFiles:

```
import type { OurFileRouter } from '~/app/api/uploadthing/core'
import {generateReactHelpers} from "@uploadthing/react";

export const { uploadFiles } = generateReactHelpers();
```

my router:

```
import { createUploadthing, type FileRouter } from 'uploadthing/next-legacy'
import {currentUser} from "~/lib/auth";

const f = createUploadthing()

export const ourFileRouter = {
imageUploader: f({ image: { maxFileSize: '4MB' } })
.middleware(async (req) => {
console.log(req)
const user = await currentUser()
if (!user) throw new Error('Unauthorized')
return { userId: user.id }
})
.onUploadComplete(async ({ metadata, file }) => {console.log(file)}),
} satisfies FileRouter

export type OurFileRouter = typeof ourFileRouter
```

Can someone help me

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.