I am having a curious problem where a download request from the browser will be passed onto a microservice via the Express layer that serves the frontend. The service queries the db, and generates a csv on the fly and can stream it.
Right now, I am fetching the file to my Express server, and then streaming it to the browser.
Is there a way I can directly pipe the file to the browser without exposing the micro-service endpoint ?
Related
I have a MEVN Stack app. This requires to upload media files to the database. From the client-side, I am posting a multipart type form which will send the file to the server through Axios. I don't know how to store that in the MongoDB database and retrieve the same.
What you are looking for, is creating an API in node.js to handle uploaded file. (You can use express.js to make your life easier if you are not already using it)
In Vue.js create a component to upload a file and store the files in the file system on the server might be in a folder that is accessible through the web server (like in a public folder).
Finally, save the URL to access the file in MongoDB so, you can reference it later. You can google for tutorials on this, an example is here.
I want to build a backend server api that expose an endpoint POST /api/v0/<entity>/upload.
This endpoint receive a large file (from hundreds MB to 2G ) and some meta data through HTTP request body. It upload the file to AWS S3 and return the progress back to front-end through HTTP response, so that front-end can use the progress and show it onto UI.
The reason why I want to put upload progress behind server is because I don't want to expose AWS ACCESS KEY on browser.
The concept is like using server as an S3 upload proxy, but with additional tasks such as create a database record that reference the uploaded file's url.
Anyone known how to build this? Or is there any better solution or thoughts on this? Thanks!
I am developing a web app and would like to stream file uploads straight to S3 (or Minio in my development environment). It doesn't look like koa-better-body or koa-body can stream, what might be a way I can do it?
You can access the original request in the context via ctx.request.req: https://github.com/koajs/koa/blob/master/lib/application.js#L153
With this you should be able to use express tools for what you need.
I've read a million different pages on how to send a file to node js from some client, but that is NOT what I'm looking for. I'd like to send a file from out client side code to a 3rd party storage system, but they don't account for the options preflight method and there is nothing I can do about that, nor can I use a different 3rd party service.
So what I'd like to do is send a file from the client, to our node js backend service, and then from the service, send the file to the 3rd party. I understand and have done many times, http request from node but I'm always sending an object of some sort. The difference here is that the object I want to send is a file.
Question: How do I get a file object together and then send that through an HTTPS PUT?
PS: I'm also running just plain vanilla node js.
I am new to working with images in web development. We have a Node.js Express server that will run on Heroku and uses Cloudinary to store images.
Ideally we could save images directly to Cloudinary, but I am not sure if that's possible and we are afraid of putting our Cloudinary credentials on the client.
Assuming we must send images data to our server first instead of sending them directly to Cloudinary - if the images are encoded as base64 on the client, is it possible to stream the images from the client to the server - or must we send all the data at once? Either way, what headers do we use to send binary / base64 data?
is it possible to send or even stream binary data from the client to the server?
since it is a Node.js server, it would be ideal to use streams and to stream the file from our server to Cloudinary.
hope this makes sense, and info would be very helpful.
Why not using direct uploads from the client side to Cloudinary using the jQuery plugin?
This method supports both signed or unsigned uploads, when the signature can (and should) be generated on your server before rendering the page, for privacy reasons. Uploading from Base64 URI is also possible with this mechanism.
Note that Cloudinary's client-libraries also wrap this plugin and provide you with "off the shelf" solutions for embedding the upload-fields in your web app, with the signature already inside.
Let us know if you need any further guidance.