Forwarding files to another service.
See original GitHub issueHello,
First of all, thank you for this awesome library 😃
I have a question: How do you suggest forwarding the files that we receive in a resolver to another service? Currently, I write the file locally with stream.pipe(createWriteStream(filename))
and then forward that file to the other service that I want. But I think there should be a better way to achieve this.
Is it BusBoy that is stopping me from doing that? Because, I remember looking at formidable and it gives me the entire file object, but BusBoy seems to only give few of the fields from the File object and does some ‘magic’ under the hood?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Forwarding multipart/form-data to different service (python ...
Problem I am facing is not able to forward request data and files attached as it is, below is code example. @post('/') def...
Read more >.forward Files (System Administration Guide, Volume 3)
Users can create a .forward file in their home directories that sendmail uses to redirect mail or send mail to a custom set...
Read more >Port Forwarding for File Sharing
We explain how to use port forwarding to transfer files and describe the types of file sharing that use port forwarding.
Read more >How to Send Large Files Over the Internet - PCMag
Here are several ways to send large files over the internet. Store Files Online. icloud. One easy solution is to upload the file...
Read more >How to Use Store-and-Forward Transfers - TechDocs
A store-and-forward transfer can be used to transfer a file indirectly when a destination system is not available. You can send a file...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
When resolving the upload, I suggest:
Create a unique file ID.
Store the image under that ID in the cloud (e.g. S3, Digital Ocean Spaces, etc.).
Use a thumbnailing/CDN service like imgix. Use it to extract image metadata.
If the metadata is not valid, delete the S3 file and resolve validation errors.
In your database, record the image under the file ID along with key bits of metadata (user ID, image dimensions, etc.).
Make an
Image
type. Mine looks like this:The
url
resolver simply constructs an imgix url for the file ID. If you’re lazy you could just make it return the base URL, and document that the user needs to append their own query string for size, etc.Hi @bhargavcp,
You shouldn’t need to create an intermediary file, but should simply be able to pipe the upload’s contents to your external service. The fields that are available (name, type, etc) are everything that is available before the entire content has streamed in. Anything that is calculated from the actual contents (a hash, size, etc) require that the stream be completely consumed. If you need any of these, you can use the
createReadStream()
API fromv7.0.0
to compute these while the upload’s contents stream to a permanent location: