I am trying to upload a pdf file from client to my server.
I know how to read a file using node js "fs" module but how to read a file which is not on my server (i.e is on client disk). There is a upload button which chooses the file and then from client side I want to send that file in stream to my server. And then I can write the stream into a file on my server.
How are the packages like ostrio:Files doing it?
Maybe this could help you https://github.com/VeliovGroup/Meteor-Files
Great package to ease the upload and storage of files :)
Hope it helps,
Regards,
Yann
Related
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.
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?
I'm about to start a project that will involve the user uploading audioMP3 files less than 16MB, which is less than the maximum file size for mongoDB. I have been searching but with no luck on how to implement this in the server side to recieve the mp3 file, save it to the DB and retrieve in the client. Any one done something similar or got any idea how to implement this specially the node express side.
Yes Thank you, what I finally did was to load the files in AWS and store their url MongoDB, later requested for them in my application and load them in the browser
I have some files in GridFS and I want to download them to the browser. It is my understanding that I need to take the file from GridFS and move it to the server's file system in order to send it to the browser.
Can someone point me in the right direction on how to do this? Specifically how to move the file from GridFS to the server's file system. I am using a node.js server with the Express.js module.
Extracting the file to the filesystem it is not required. Have a look at this one (it works with an image, but I think you can do the math): https://stackoverflow.com/a/9848915/733749
Clients can upload files by using a Multi-part form post to my node.js application. To handle the file upload I'm using the node-formidable library.
Now, I manage to upload the file in chunks to node but I don't want it to be buffered before it's written to disk. So, I'm trying to understand how I can write the file data chunks to disk when they're received. I don't fully understand the node-formidable api how to acheive.
Can someone give a simple example of how to listen for an incoming file, create a file stream and then access the data coming in and write that data to the stream and finally closing the stream.
Thanks for help!
There is one example here. It doesn't use formidable library but a similar module (multipart). But it explains everything that you have asked for. You can massage it to fit you needs.
Thanks,
KA