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

TypeError: stream.getReader is not a function #460

Closed
LWJerri opened this issue Jun 19, 2021 · 2 comments
Closed

TypeError: stream.getReader is not a function #460

LWJerri opened this issue Jun 19, 2021 · 2 comments
Assignees

Comments

@LWJerri
Copy link

LWJerri commented Jun 19, 2021

When I try to get file extension and mime type I'm getting the error TypeError: stream.getReader is not a function.

My code:

  return responses
    .map((r) => r.data)
    .filter(async (image) => {
      const fetchedURL = got.stream(image.url) as any;
      const fileInfo = await FileExt.fromStream(fetchedURL);

      fileTypes.includes(fileInfo.ext);
      console.log(fileInfo.ext); // stream.getReader is not a function
    });
@LWJerri LWJerri closed this as completed Jul 4, 2021
@LWJerri LWJerri reopened this Jul 4, 2021
@Borewit
Copy link
Collaborator

Borewit commented Jul 5, 2021

It is a bit guess work to get your example running, this was my interpetation:

const got = require('got').default;
const FileExt = require('file-type');

function getResponeses(r) {
  r.map((r) => r.data)
    .filter(async (image) => {
      const fetchedURL = got.stream(image.url);
      const fileInfo = await FileExt.fromStream(fetchedURL);

      console.log(fileInfo.ext); // stream.getReader is not a function
    });
}

getResponeses([
  {data: {url: 'https://github.com/sindresorhus/file-type/raw/main/fixture/fixture.jpg'}},
  {data: {url: 'https://github.com/sindresorhus/file-type/raw/main/fixture/fixture.png'}},
  {data: {url: 'https://github.com/sindresorhus/file-type/raw/main/fixture/fixture.gif'}}
  ]);

Running it with Node.js outputs:

jpg
png
gif

@Borewit Borewit self-assigned this Jul 5, 2021
@LWJerri
Copy link
Author

LWJerri commented Jul 5, 2021

Hmm, okay. Thanks for your answer, problem solved!

@LWJerri LWJerri closed this as completed Jul 5, 2021
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