how to save the binary of image of multi part form in node js - node.js

upload imageI am trying to make upload image in pure nodejs, please don't ask me why you do that cuz I am obliged to make it in pure node js I parsed the request header and I checked about image uploading or any files and I have in the console these bytes of image req data. and I**strong text** am tried to save it with fs module and the image saved successfully but when opening it gives me "this file format can't be opened"
how can i save the uploaded image ??

Related

How to read xlsx content downloaded using content-disposition node

Is there any method to read the downloaded file content(not the file name) using node js? I'm getting my downloaded file content-disposition: attachment;filename=hello11.xlsx like this. I want provide the URI to my excel data extraction function. but couldn't figure out how to get the URI because my get Request returns nothing but a file downloaded to the browser.
I found a similar question but it's using java

Unable to use puppeteer in a nodejs app on cpanel?

I am using puppeteer in my nodejs application to convert html file into pdf. This is working fine in my local server and pdf is getting generated. But this is not working in cPanel. I am getting error similar to this. I tried everything mentioned on that but nothing works.
I tried setting the executable path of chrome in puppeteer in cpanel but in vain. Errpr =>
Failed to launch the browser process!
/home/xxx/public_html/xxx/node_modules/puppeteer/.local-chromium/linux-1002410/chrome-linux/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory
I tried different packages like html-pdf and node-pdf-generator. But the problem is I have designed some ejs templates according to chrome and then I am generating html files from these ejs templates. After that I am saving the pdf file in buffer and uploading this buffer to google bucket.
Flow: ejs templates -> html file -> pdf buffer -> stream buffer to gc
bucket
In other packages I am facing these issues:
Either the template is not coming as expected
Or The package has no option of storing generated pdf file in buffer.
Any solution or a different library?

How to upload text file (.txt) in cloudinary using nodejs?

I have a text file with extension ".txt" that needs to be uploaded on Cloudinary. Cloudinary is not allowing me to do that.
Any help on this will be appreciated.
What do you mean upload ".txt"?
I googled it and first few seconds into the research I found this:
[![enter image description here][1]][1]
[![enter image description here][2]][2]
It's a image/video hosting service not a cloud storage service.
But there are tons of such services that allow uploading
[1]: https://i.stack.imgur.com/b09yV.png
[2]: https://i.stack.imgur.com/aGbyO.png
You didn't specify what error you're receiving, but Cloudinary does support non-image, non-video uploads, which are called 'raw' files: https://cloudinary.com/documentation/upload_images#uploading_non_media_files_as_raw_files
A possible error you may encounter is if you haven't set the resource_type to raw in your API call, or if you've set resource_type to auto but the filename of the uploaded file wasn't sent on the upload API call. In that case, it's likely that Cloudinary was expecting an image file, and didn't detect that you sent a .txt file.
If so, you'll receive an 'invalid image file' error if the file was treated as an image - specifying the resource type explicitly should resolve that

Nodejs transform image data back to actual image

My server receives a file from a HTTP request and uploads this file to IBM Cloud Object Storage.
Moreover, the server allows to recover this file. Recovery is triggered by a get http request that should return said file.
It works fine for "basic" data format, such as text files. However, I encounter problems with more complex types such as images and the "reformating".
Image is uploaded to the datastore. The element stored is the buffer itself:
req.files[0].buffer
When getting the image back from the datastore, how can I transform it back to a readable format for my computer?
The data look like this and it is, on the server, a string:
If you are using ExpressJS you can do this:
const data = req.files[0].buffer;
res.contentType('image/jpeg'); // don't know what type is
res.send(data);

Uploading large tiff files in nodejs

I am developing a web app using MEAN Stack and Angular 6. I want to upload tiff files(maps) with large file size.(max size is around 1.4 GB).I used 'ng2fileUpload' and 'multer' for that but it does not allow to store large files. Is there any good method to use for uploading large files in nodejs. My preavious post is on this link. 'Uploading files using multer gives 'request entity too large' error'
You should check first if there is a limit on max upload on the server site instead of the client side. There is a limit with apache service.

Resources