Skip to main content
Question

Box Node SDK - files.getReadStream(fileID, qs, callback)

  • May 21, 2025
  • 4 replies
  • 61 views

Forum|alt.badge.img

Is there any documentation on what "qs" getReadStream supports?

4 replies

Forum|alt.badge.img

 The qs parameter lets you pass in any of the optional parameters for the Download File endpoint including "Range", "version", and "BoxApi".

 

The "Range" parameter lets you query a specific range of a file in bytes. The "version" parameter lets you download a specific version of a file. The "BoxApi" parameter lets you specify a shared link to a file, which lets you download a file that you might not be collaborated with in your account.

 


Forum|alt.badge.img

Thanks for the response . Using the example provided in the SDK, I'm calling it via:

 

var opts = {
"Range":"bytes=0-500000"
};
client.files.getReadStream('12345', opts, function(error, stream) { if (error) { // handle error } // write the file to disk var output = fs.createWriteStream('foo.jpg'); stream.pipe(output); });

The file on Box is 1.1MB, and the output file 'foo.jpg' is also 1.1MB, which is not what I would expect given a truncated Range. Are the opts formatted properly, or am I missing something else?


Forum|alt.badge.img

 

 I incorrectly noted in my response above that Range was a parameter. Range is a header. There was an error in our documentation that we updated this past week. Sorry for the confusion.


Forum|alt.badge.img

Thanks 

 

I actually worked with Box Support and the Documentation team to test this out and come to the conclusion that Range/BoxAPI were headers not query strings. I believe the documentation was just updated to indicate this. Thanks for your help.