In case we upload a file from gateway API, I wonder how to stream the uploaded file to a remote service ?
For this, we need stream supporting on request side (in broker.call)
Depending on the transporter that you are using, it may or may not make sense to upload file via moleculer.
If you are, say, uploading a small json file, then it probably makes sense to do an RPC call.
However, if you are trying to upload, say, a use profile picture, then it probably makes more sense to:
1) do an RPC call to generate a pre-signed URL
2) upload the said file to S3/S3-compatible storage with the URL
3) do another RPC call with the URL, so the remote service can process.
This would avoid the slow consumer problem and reduce the bandwidth usage in the transporter channel (especially if you are using gnatsd then it has strict some requirements).
Most helpful comment
Depending on the transporter that you are using, it may or may not make sense to upload file via
moleculer.If you are, say, uploading a small
jsonfile, then it probably makes sense to do an RPC call.However, if you are trying to upload, say, a use profile picture, then it probably makes more sense to:
1) do an RPC call to generate a pre-signed URL
2) upload the said file to S3/S3-compatible storage with the URL
3) do another RPC call with the URL, so the remote service can process.
This would avoid the
slow consumerproblem and reduce the bandwidth usage in the transporter channel (especially if you are usinggnatsdthen it has strict some requirements).