li-raz
li-raz

Reputation: 1696

use fastify to download big files as multipart

I have a code that download big objects from S3 using multipart download. I am working now on a microservice that will hide all the s3 operations and in the future will give me the flexibility to change to any object store.I have created a nodejs service using fastify, how can I add the support of multipart download using fastify?

Upvotes: 0

Views: 1327

Answers (1)

Manuel Spigolon
Manuel Spigolon

Reputation: 12900

You should rewrite the parts logic of AWS-S3 service in server and client side too.

The GetObject accepts the Range header that will limit the download of that piece of file.

So the client need to know how many pieces compose a file, using the ListParts API usually. Then it can call the GetObject with the range parameter:

 var params = {
  Bucket: "examplebucket", 
  Key: "SampleFile.txt", 
  Range: "bytes=0-9"
 };
 s3.getObject(params, function(err, data) {...

So your Fastify server should proxy at latest those 2 services to let the client download simultaneously many pieces of the file and then merge them.

Upvotes: 1

Related Questions