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

Buffer doesn't work #63

Closed
NetOpWibby opened this issue Jan 21, 2018 · 2 comments
Closed

Buffer doesn't work #63

NetOpWibby opened this issue Jan 21, 2018 · 2 comments

Comments

@NetOpWibby
Copy link

At least in the way I'm attempting to do it. I'm working on a microservice to do image conversion.

async function convertWebp(data) {
  // data.blob.headers["content-type"] = "application/octet-stream";
  const buf = await buffer(data.blob, { limit: "5mb" });

  imagemin(buf, "build/images", {
    use: [
      imageminWebp({ quality: 80 })
    ]
  }).then(files => {
    log(files);
  });
}

The error I get in the console is:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 21): TypeError: Cannot read property 'content-type' of undefined

As you can see in the comment I left in my code, I tried adding headers but I assume I'm not doing this right. Does anyone have any insight into what I'm doing wrong?

@tungv
Copy link
Contributor

tungv commented Jan 22, 2018

Assuming you export this function as the default export (es6) or via module.exports =, headers can be accessed by data.headers. data is an http request in nodejs

@NetOpWibby
Copy link
Author

My solution was to not use it. I found another to do what I was aiming to do.

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