kolkov / angular-editor

A simple native WYSIWYG editor component for Angular 6 -14+
https://angular-editor.kolkov.ru
MIT License
675 stars 361 forks source link

Bad request error when tried to upload image on custom endpoint #181

Open Ajinkya1496 opened 4 years ago

Ajinkya1496 commented 4 years ago

Hello,

I am using this text editor in my Angular 8 project. I am trying to upload image on my server and returning imageUrl in respone.

uploadUrl: 'http://localhost:3000/v1/image'

With the help of interceptors I generate a file with random string and return that same file.

@UseInterceptors(FileInterceptor('content_images', {
    storage: diskStorage({
      destination: 'src/assets/content_images',
      filename: (req, file, callback) => {
        const randomName = generateImageName();
        return callback(null, `${randomName}${extname(file.originalname)}`)
      }
    })
  }))
  @Post('v1/image')
  async uploadContentImage(@Req() req: Request, @UploadedFile() file) {
    console.log(ENV.domain+file.path)
    return {
      imageUrl: ENV.domain+file.path
    }
  }

In the console at frontend side I get below error image

Can someone help me with this?

Thanks, Ajinkya

kcs-renusuthar commented 4 years ago

Hi @Ajinkya1496 , Have you resolved this?

Ajinkya1496 commented 4 years ago

Not yet! I still have my apis as mentioned above but no luck so far in making it work!