Optionalqueryquery strings should go here instead of being part of the pathname.
moreover, it should not include the leading "?" query character, and boolean query keys should always be followed with an "=" equals sign
for instance, for the url "http://localhost:9000/default/temp/hello_world.txt?attributes&max-keys=20", the query string "attributes=&max-keys=20"
[!note]
amazon requires you to sort the query parameters by their key names, according to: link. so the s3 signer functions perform the query-parameter sorting automatically.
Optionalpayloadprovide the payload (string or ArrayBuffer) of your request's body so that the sha256 hash of it can be computed and signed as a part of the header.
you have various hashing options to choose from, based on what you provide:
string | ArrayBuffer: this will be treated as the payload, and its SHA256 will be computed and appended to the "x-amz-content-sha256" key of your header.{ sha256: string | ArrayBuffer }: if you provide an object with the member sha256, then this value will be used, and no SHA256 computation of a payload will take place.
this is useful if you have already computed the SHA256, or maybe you don't have the payload, but only its SHA256 is available to you.
you can use the sha256 helper function to compute the hash yourself.{ unsigned: true }: if you provide an object with the member unsigned, then it will be assumed that your request's body (payload) will not be cryptographically encrypted,
and sent out without encryption. or maybe there is no payload to encrypt.
under the hood, this option will set the "x-amz-content-sha256" header's value to "UNSIGNED-PAYLOAD", which, I guess, understood by many S3 implementations.
GET requests do not have a body, thus their payload can be considered to be either an empty string (""), or { unsigned: true }
Optionalheadersadditional headers to include in your request. you can use these headers to overwrite some of the following default/computed header fields (which are required to be part of the final header):
"host": the domain name/host server (without the http uri scheme)."x-amz-date": the date and time the request was made (example: "20240920T000000Z").
also see the date field for setting a custom amazon formatted date and time."x-amz-content-sha256": the sha256 hash of the request's body.
since a GET request cannot have a body, this is the sha256 of and empty string during a get request (default).Optionaldateuse a custom date, based on what you provide:
number: use a specific epoch time in milliseconds. for example: 1726790400000 (this comes from new Date("2024-09-20T00:00:00Z").getTime())."now": use Date.now() as the time.string: use an amazon formatted string date. example: "20240920T000000Z".any of the value that you provide here is internally converted into an amazon formatted string date, which is required when signing.
Optionalservicename of the service being used. typically it is "s3"
Optionalmethodwhich http method will you be using?
Optionalregionwhat is the region of the server? for locally hosted minio, use the default value.
configuration options for the s3SignHeadersV4 function.