Unable to handle body data along with image file in Nestjs - nestjs

I want to send image file along with various data.
The issue is when i send file using formdata/multipart the body data comes in string. So my dto is giving error.
Is there any way to parse cetain fields to number/array before it reaches the dto??

This happens only with postman, in Postman formmultipart everthing is sent as text. Wont happen when you use Axios in front end

Related

Extracting SOAP response values, then printing them on an external file using PyCharm

Hope your doing great.
I'm using this soap request for test issues and I want to parse some of the values in the response and take those values using a for to an external .text file without overwriting them. So this will allow me to execute it various times getting different values.

DocuSign eSign REST API How to handle PDF response in PHP?

I'm trying to get all documents in an envelope as a single PDF, if I call this REST API URL:
/v2/accounts/{$accountId}/envelopes/{$envelopeId}/documents/combined
It returns a bunch of data, however, I can't find a way to store this data as a valid PDF. When I output the content with headers it does download a file, but it's not a valid PDF. Also when I store the content in a file, it will not be a valid PDF file.
Anyone encountered this problem and knows how to solve this?
The content comes back as a file, you have to read the temp file and save that to the desired file
Quick snippet using file_get_contents and file_put_contents
$docStream = $envelopeApi->getDocument($accountId, 1, $envelopeId);
file_put_contents("my_document.pdf", file_get_contents($docStream->getPathname()));
More info DocuSign REST API :: EnvelopeDocuments: get under Get a Single Document as a PDF File

postman request to upload a file

I am at this site : https://www.free-ocr.com/ which allows you to upload a file and in response returns text from that file.
When I upload a file it creates a POST request with multi-part form data with the following headers.
In return it gets the folowing response, the one in which I am interested :
However, when I try to replicate this whole thing in POSTMAN using POST method and upload a file using form-data, I do not get the same response as it was intended. Can somebody help me sort out what am I doing wrong?
you just need to select type as file in body
then select the file .

Rendering Blob Buffer to PDF in Express/Node Response

Very strange, i am pulling my blob data out of my SQL Server, then returning it to my Express server. I then want to send it as a pdf file out to my res.send(). However im getting a big jumbled up pdf. It has the correct amount of pages, however instead of rendering the PDF it is supposed to, i just have a bunch of random lines and squares on the PDF.
The strange part is doing this the exact same way on a simple Express server works 100%, however trying to implement this on my production app that was generated with Yeoman fullstack, i now get this undesiered result.
Whats the best way to render my array buffer to a PDF and display it to the res as a pdf file? Thanks
My current code (this is the working method in the basic Express Server)
res.setHeader('Content-type', 'application/pdf');
res.send(recordset[0].ordaAttachment);
recordset[0].ordaAttachment is just a PDF buffer in the format below. (This is just an example and not the real PDF)
{"type":"Buffer","data":[37,80,68,70,45,49,46,51,13,37,226,227,207,211,13,13,49,32,48,32,111,98]}

Download multiple PNGs with one request/response (nodejs)

I have one specific problem:
I have a single request, sent to an nodejs express application, which shall return multiple PNGs. The result is displayed directly in an image in the browser.
image.src = http://www.....
The PNGs are created server side, but I do not manage to send them back in one response and display them client side in the browser as images.
I piped the PNG content in a stream, which I sent back. I closed the stream at the end, when all files were sent back. I did not call res.end() in between.
What happens is that I receive a PNG File, really big (so I know it contains the data of all the images I requested), but my image in the browser only displays the first PNG - and I dont know how to split the response client side to view all my images.
I even can't view the PNGs if I download them directly on my pc (by calling the request manually) - the returning PNG is really big, but does only display the first PNG when I open it for example in gwenview.
It is no option to send the pngs in an zip file and extract it client side, because not all browser do support the unzipping. (I had a hard time learning this) I really dont know how to solve this problem. Do I need to set a specific header type I do not know yet? Do I need to send some delimiter inbetween the PNGs? How can I split the returning PNG client side?
Some help would be really appreciated!
Thank you!
There's no MIME type for multiple images. Your best bet is to generate a single html page and then embed the images in it. If you don't want to keep any of the images on your server, you can embed them using a data URL: https://github.com/heldr/datauri
An alternative option is use node-canvas to combine multiple images into one large one.

Resources