How to use the util function from aws-sdk

Find comprehensive JavaScript aws-sdk.util code examples handpicked from public code repositorys.

aws-sdk.util provides utility functions for working with the AWS SDK for JavaScript.

531
532
533
534
535
536
537
538
539
540
/**
* Patch S3 createBucket invocation to not add a LocationContraint if the region is `us-east-1`
* The default SDK check was against endpoint and not the region directly.
*/
patchS3CreateBucketLocationConstraint () {
  AWS.util.update(AWS.S3.prototype, {
    createBucket: function createBucket (params, callback) {
      // When creating a bucket *outside* the classic region, the location
      // constraint must be set for the bucket and it must match the endpoint.
      // This chunk of code will set the location constraint param based
fork icon81
star icon457
watch icon0

+ 75 other calls in file

-3
fork icon0
star icon0
watch icon1

+ 57 other calls in file

How does aws-sdk.util work?

aws-sdk.util is a module provided by the AWS SDK for JavaScript that provides a set of utility functions for working with AWS services. These functions include common tasks such as converting between data formats, parsing AWS error responses, and calculating signatures for AWS requests.

One example function provided by aws-sdk.util is the AWS.util.date.parseTimestamp function, which is used to parse timestamps in ISO 8601 format that are commonly used in AWS APIs. Another example is the AWS.util.buffer.toStream function, which is used to convert a Buffer object to a Readable stream for use with AWS services that require streaming data.

Overall, aws-sdk.util is a useful set of utility functions that simplify working with AWS services in JavaScript.

199
200
201
202
203
204
205
206
207
208
209
}


const invokeLambda = async function (functionName, context, payload) {
    const params = {
        FunctionName: functionName,
        ClientContext: AWS.util.base64.encode(JSON.stringify(context)),
        //FetchStoreInfo needs to wait. WriteToCache does not need a response
        InvocationType: functionName == lambdaFunctions.FetchStoreInfo ? "RequestResponse" : "Event",
        LogType: "Tail",
        Payload: JSON.stringify(payload)
fork icon0
star icon0
watch icon1

+ 43 other calls in file

Ai Example

1
2
3
4
5
const AWS = require("aws-sdk");

const myString = "Hello, world!";
const myBuffer = new AWS.util.Buffer(myString);
console.log(myBuffer.toString());

This code will output the string "Hello, world!" after converting it to a buffer and then back to a string using the toString() method.