How to use the MediaStoreData function from aws-sdk

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

aws-sdk.MediaStoreData is a client library for accessing and manipulating data stored in Amazon Web Services' MediaStore service.

262
263
264
265
266
267
268
269
270
} = await this.describeContainer(ContainerName);
if (!Endpoint) {
  throw new Error(`Container ${ContainerName} endpoint null`);
}

const instance = new MediaStoreData({
  apiVersion: '2017-09-01',
  endpoint: Endpoint,
});
fork icon0
star icon0
watch icon1

+ 78 other calls in file

How does aws-sdk.MediaStoreData work?

aws-sdk.MediaStoreData is a client library that provides an API for interacting with data stored in Amazon Web Services' MediaStore service. MediaStore is a scalable and durable storage service designed for media content, such as images, videos, and audio files. The aws-sdk.MediaStoreData client library provides a set of methods that can be used to upload, download, and manage media content stored in MediaStore. These methods include: getObject: Retrieves an object stored in MediaStore and returns it as a stream. putObject: Uploads a new object to MediaStore. deleteObject: Deletes an object stored in MediaStore. The aws-sdk.MediaStoreData library uses the AWS SDK for JavaScript to communicate with the MediaStore API. The library provides a simplified interface for working with the MediaStore API, hiding many of the low-level details of the API behind a more user-friendly API. Here's an example of how you might use the aws-sdk.MediaStoreData library to upload a file to MediaStore: javascript Copy code {{{{{{{ const AWS = require('aws-sdk'); const mediaStoreData = new AWS.MediaStoreData({ apiVersion: '2017-09-01' }); const params = { Body: 'Hello, world!', Path: '/example/file.txt', ContentType: 'text/plain', StorageClass: 'TEMPORAL' }; mediaStoreData.putObject(params, function(err, data) { if (err) { console.log('Error uploading file: ', err); } else { console.log('File uploaded successfully.'); } }); In this example, we first import the aws-sdk library and create a new instance of the MediaStoreData client. We then define a set of parameters that describe the file we want to upload, including the file contents (Body), the file path within MediaStore (Path), the content type of the file (ContentType), and the storage class of the file (StorageClass). We then call the mediaStoreData.putObject method, passing in the parameters we defined and a callback function that will be called when the upload is complete. If an error occurs during the upload, the callback function will log an error message to the console. Otherwise, the function will log a success message to the console. Overall, aws-sdk.MediaStoreData provides a convenient and user-friendly way to interact with data stored in MediaStore. It simplifies many of the low-level details of the MediaStore API, allowing developers to focus on building applications that use media content without worrying about the underlying infrastructure.

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const AWS = require("aws-sdk");
const fs = require("fs");
const mediaStoreData = new AWS.MediaStoreData({ apiVersion: "2017-09-01" });

const params = {
  Path: "/example/file.txt",
};

const file = fs.createWriteStream("./file.txt");

mediaStoreData
  .getObject(params)
  .createReadStream()
  .pipe(file)
  .on("error", function (err) {
    console.log("Error retrieving file: ", err);
  })
  .on("finish", function () {
    console.log("File retrieved successfully.");
  });

In this example, we first import the aws-sdk and fs libraries and create a new instance of the MediaStoreData client. We then define a set of parameters that describe the file we want to retrieve from MediaStore, including the file path (Path). We then create a new write stream to a local file using the fs.createWriteStream method. We call the mediaStoreData.getObject method, passing in the parameters we defined. This method returns a response object that includes a createReadStream method. We call this method to get a stream that represents the contents of the file stored in MediaStore. We then pipe the stream returned by createReadStream to the write stream we created earlier, saving the contents of the file to a local file. Finally, we define event handlers for the error and finish events of the write stream. If an error occurs while retrieving the file, the error event handler logs an error message to the console. Otherwise, the finish event handler logs a success message to the console. Overall, this example demonstrates how you can use the aws-sdk.MediaStoreData library to retrieve and save files stored in MediaStore to your local file system.