Save uploaded file at nextjs custom server - node.js

I used the antDesign file upload component in one form. After the file is fully uploaded, I save the file information in the model I want to send to the server (the output of the file upload component is attached). Now my question is how should I save the file on the server with this information? Files are sent in different formats (png, jpg, pdf, ...) and I am looking for a solution to store these files on the server.

You should use originFileObj, get it and then append it to FormData, and afterward send it by using axios or fetch. There is an example in the antd documentation about it

Related

Sending client file download link

I have a nodejs backend and I want to send a file download link to the client such that, the file is directly accessible by the client. The file types are JPEG and PNG. Currently, I am serving these files as data-uri but, due to a change in requirements, I must send a download link in response to the file request and, client can download the file later using that link.
Now the current workflow exposes a path /getAvatar. This path should send a response back to the client with the file link. The file, is stored in /assets/avatars relative to the server root. I know I can express.static middleware to send back static resources. However, the methods I have seen so far, res.send() and res.download() both tries to send the file as attachment rather a link that can be used later to download.
Basically, the behavior is like a regular file sharing site where, once a file is clicked, a link to it is generated which, is used for downloading the file. How can I do this?

Get PDF file from Nodejs and have copy in angular physical directory

I have an angular application that has a feature to render the pdf in the client side with the help of ng2-pdfviewer, that reads the file from the local directory from the client side.
Now I have an upload option which uploads the pdf files to the server and storing it in local uploads directory in the server side. Now I want to read the physical pdf file available in the server instead of downloading as blob and saving.
Does anybody have any suggestions on how to do this?
ng2-pdf-viewer accepts both an UInt8Array (that fits your former approach on reading from a file utilising FileReader, for instance) or a string (that can contain a remote URL) on its src parameter.
So, as far as you have the complete URL for your target PDF, you can provide it as the source for rendering.

Angular 5 Download file from dropbox and Upload it to AWS s3

I am currently using dropbox file picker to download the file. I got the download link after selection of file using dropbox picker.
Is there any possibility that we can save it inside bytestream in browser and upload it to server(Node.JS) using http post call ?
Or Is there any alternative to this scenario ?
Any help would be appreciated.
Instead of downloading and reuploading the file on the browser, I would have this step to be processed on the server side.
You can use Dropbox and S3 sdk's and follow the steps below:
Make a call to the server that will send IDs of the list of files available in Dropbox.
Let the user select a file in the angular app and send the selected file's resource identifier back to the server.
Download the file and then re-upload it to the S3 on the server side.
Display the result/status back to the user.
Is there any reason you want this to be done in the frontend?

What are the possible ways to transfer a file of more than 100MB generated via shell script, to any URL or server?

I have a shell script written, which generates an excel file of more than 100MB. Now, I want to transfer the file or say upload the file to one URL which is online storage server. This server will generate a URL containing the file after uploading.
The question is if we are able to upload the file using "cURL" to any given URL, then how to get the generated URL from that web page??
The URL generated after uploading the file is dynamic. (Dropbox kind of storage)
If it is not possible to get that URL then how to transfer such a big file.
Note: It is kind of automation, so please answer keeping automation in mind.
Thank you in advance.

how to read a pdf file using nodejs/expressjs

how to read a pdf file using nodejs ?
I have two issues:
1)I have a pdf file and i just want to read it and and display the contents in the browser.
2)Read and display the content of a specific page of file
If you want node to display a PDF file to a browser, you can simply have node send the PDF file upon HTTP request: res.sendFile('./example/file.pdf');
This previously answered question has more options and further details for sending PDF to the browser.
If you are trying to read (parse) the contents of the PDF, you can use pdf2json to figure out what part of the PDF file you want to display.

Resources