-
-
Notifications
You must be signed in to change notification settings - Fork 395
Closed
Labels
Description
import got from 'got';
import {fileTypeStream} from 'file-type';
const url = 'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg';
const stream1 = got.stream(url);
const stream2 = await fileTypeStream(stream1, {sampleSize: 1024});
if (stream2.fileType && stream2.fileType.mime === 'image/jpeg') {
// stream2 can be used to stream the JPEG image (from the very beginning of the stream)
console.log('works');
}Throws an error:
Error: Failed to pipe. The response has been emitted already.
at Request.pipe (C:\Users\Borewit\code\github\examples\node_modules\got\dist\source\core\index.js:1476:19)
at Function.pipeline (node:internal/streams/pipeline:284:13)
at Request.<anonymous> (C:\Users\Borewit\code\github\file-type\core.js:1432:26)
at Object.onceWrapper (node:events:513:28)
at Request.emit (node:events:394:28)
at emitReadable_ (node:internal/streams/readable:571:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
Reactions are currently unavailable