SaltwaterC edited this page Mar 23, 2012 · 3 revisions


Low level method for sending GET requests to the S3 REST API.


s3.get(path, [query], resBodyHandler, callback)
  • 'path' - the S3 Path.
  • 'query' - optional argument that is a {key: value} object for specifying query arguments. They may be specified in the path argument. Basically this argument is just syntactic sugar for making things easier to understand. In the end, the contents of this argument are merged into the path argument.
  • 'resBodyHandler' - the Response Body Handler.
  • 'callback' - the callback that is executed when the processing finishes. It has a couple of arguments: error and result.
    • If there's an error, the callback receives the error argument as Error instance.
    • If the error argument is null, then the response argument contains the response data as decided by the resBodyHandler.

These calls are equivalent:

s3.get('?uploads&max-uploads=1', 'xml', callback);
s3.get('?uploads', {'max-uploads': 1}, 'xml', callback); // (since v0.6.7)
s3.get('/', {uploads: null, 'max-uploads': 1}, 'xml', callback); // (since v0.6.10)

You must pass exactly the null value into the query argument for parameters that must not have a value. Typically these are the S3 subresources as defined by the S3 Developer Guide.