0

I need to send a image as blob via a nestjs api when i log the blob it comes perfect console.log(blob) but when i call it with insomnia it returns a blank object Insomnina response

I tried calling in the front and converting to a blob again but it seems like it lost data since the size was shrink to 15 from 50k+

1 Answers1

0

You may want to take a look at the official NestJs documentation about streaming files here. But first, if what you're trying to do is to return a readable stream from a buffer with no file involved, then you need to handle that buffer first as discussed in this answer. Then you can simply pipe the result using stream.pipe(res).

  • The import for StreamableFile doesn't seem to work, i tried updating nestjs but it didnt work, im running the 7.6.15 `Module '"@nestjs/common"' has no exported member 'StreamableFile'.` – Murilo AA Alves Dec 05 '22 at 14:17
  • If you use the nestjs v8 or lower, you might take a look at the answer [https://stackoverflow.com/questions/53504621/how-to-return-pdf-file-from-controller]. You might want to utilize the createReadStream() function. – Farista Latuconsina Dec 06 '22 at 02:54