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

Corrupt image when uploading #629

Closed
waigel opened this issue May 14, 2020 · 6 comments
Closed

Corrupt image when uploading #629

waigel opened this issue May 14, 2020 · 6 comments

Comments

@waigel
Copy link

waigel commented May 14, 2020

Support plan

  • which support plan is this issue covered by? (e.g. Community, Sponsor, or
    Enterprise): community
  • is this issue currently blocking your project? (yes/no): yes
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: v14.0.0
  • module (formidable) version: 2.0.0-canary.20200504.1
  • environment (e.g. node, browser, native, OS): node with Next.Js
  • used with (i.e. popular names of modules): Next.js
  • any other relevant information: I use the api routing from Next.js

What are you trying to achieve or the steps to reproduce?

import formidable from 'formidable';

export const config = {
  api: {
    bodyParser: false,
  },
};

export default async (req, res) => {
  const form = new formidable.IncomingForm();
  form.on('fileBegin', (name, file) => {
    file.path = "./" + file.name

  });
  form.parse(req, (err, fields, files) => {
    console.log(files);
  });

  res.end()
};

I'm trying to upload an image as form-data to a Nextjs api route. I use the package formidable to parse and save the file in a server folder. For the http request I use postman on the client.

What was the result you got?

The image (jpeg) is saved in the folder. However, it appears to be corrupt or damaged. Here is the corrupted image:

https://i.gyazo.com/1ce276c4968dc7e1cd24da74fe380467.png

What result did you expect?

Well, the original image. (https://i.gyazo.com/6ded28032d5dd5a0f02fd2a5052a57fc.png)

@waigel waigel added the bug Something isn't working label May 14, 2020
@auto-comment
Copy link

auto-comment bot commented May 14, 2020

Thank you for raising this issue! We will try and get back to you as soon as possible. Please make sure you format it properly, followed our code of conduct and have given us as much context as possible.
/cc @tunnckoCore @GrosSacASac

@tunnckoCore tunnckoCore added area: plugin / parser and removed bug Something isn't working labels May 14, 2020
@tunnckoCore
Copy link
Member

tunnckoCore commented May 14, 2020

Thanks for the report. Does the same thing happen when other images are uploaded?

I don't have any ideas why this can happen for now. Sorry ;/

@waigel
Copy link
Author

waigel commented May 14, 2020

Yes, this applies to all uploaded images.

@tunnckoCore
Copy link
Member

Thanks. Strange... These examples from this repo work?

Oooh, that's serverless function above, right? Then try formidable-serverless until #594 if that's the case.

@waigel
Copy link
Author

waigel commented May 14, 2020

Oh, thanks, that solves the problem.
Excuse me, I didn't know this package

Thank you very much for your time!

@waigel waigel closed this as completed May 14, 2020
@tunnckoCore
Copy link
Member

Yea, sure. We should add it at least to the docs, haha.

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