@aws-sdk/client-glacier-browser
Description
Amazon S3 Glacier (Glacier) is a storage solution for "cold data."
Glacier is an extremely low-cost storage service that provides secure, durable, and easy-to-use storage for data backup and archival. With Glacier, customers can store their data cost effectively for months, years, or decades. Glacier also enables customers to offload the administrative burdens of operating and scaling storage to AWS, so they don't have to worry about capacity planning, hardware provisioning, data replication, hardware failure and recovery, or time-consuming hardware migrations.
Glacier is a great storage choice when low storage cost is paramount and your data is rarely retrieved. If your application requires fast or frequent access to your data, consider using Amazon S3. For more information, see Amazon Simple Storage Service (Amazon S3).
You can store any kind of data in any format. There is no maximum limit on the total amount of data you can store in Glacier.
If you are a first-time user of Glacier, we recommend that you begin by reading the following sections in the Amazon S3 Glacier Developer Guide:
-
What is Amazon S3 Glacier - This section of the Developer Guide describes the underlying data model, the operations it supports, and the AWS SDKs that you can use to interact with the service.
-
Getting Started with Amazon S3 Glacier - The Getting Started section walks you through the process of creating a vault, uploading archives, creating jobs to download archives, retrieving the job output, and deleting archives.
Installing
To install the this package using NPM, simply type the following into a terminal window:
npm install @aws-sdk/client-glacier-browser
Getting Started
Import
The AWS SDK is modulized by clients and commands in CommonJS modules. To send a request, you only need to import the client(GlacierClient
) and the commands you need, for example UploadArchiveCommand
:
//JavaScript
const {
GlacierClient
} = require("@aws-sdk/client-glacier-browser/GlacierClient");
const {
UploadArchiveCommand
} = require("@aws-sdk/client-glacier-browser/commands/UploadArchiveCommand");
//TypeScript
import { GlacierClient } from "@aws-sdk/client-glacier-browser/GlacierClient";
import { UploadArchiveCommand } from "@aws-sdk/client-glacier-browser/commands/UploadArchiveCommand";
Usage
To send a request, you:
- Initiate client with configuration (e.g. credentials, region). For more information you can refer to the API reference.
- Initiate command with input parameters.
- Call
send
operation on client with command object as input. - If you are using a custom http handler, you may call
destroy()
to close open connections.
const glacier = new GlacierClient({region: 'region'});
//clients can be shared by different commands
const params = {
vaultName: /**a string value*/,
accountId: /**a string value*/,
body: /**a blob value*/
/**You can supply readable stream to streaming input. e.g. (await fetch(input)).body */,
};
const uploadArchiveCommand = new UploadArchiveCommand(params);
glacier.send(uploadArchiveCommand).then(data => {
// do something
}).catch(error => {
// error handling
})
In addition to using promises, there are 2 other ways to send a request:
// async/await
try {
const data = await glacier.send(uploadArchiveCommand);
// do something
} catch (error) {
// error handling
}
// callback
glacier.send(uploadArchiveCommand, (err, data) => {
//do something
});
The SDK can also send requests using the simplified callback style from version 2 of the SDK.
import * as AWS from "@aws-sdk/@aws-sdk/client-glacier-browser/Glacier";
const glacier = new AWS.Glacier({ region: "region" });
glacier.uploadArchive(params, (err, data) => {
//do something
});
For operations containing stream response like GetJobOutput()
, you can get response stream by accessing to streaming member. e.g. data.body.getReader().read().then(/_ do something and continue reading _/).(data
is the resolved response object)
Troubleshooting
When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).
try {
const data = await glacier.send(uploadArchiveCommand);
// do something
} catch (error) {
const metadata = error.$metadata;
console.log(
`requestId: ${metadata.requestId}
cfId: ${metadata.cfId}
extendedRequestId: ${metadata.extendedRequestId}`
);
/*
The keys within exceptions are also parsed. You can access them by specifying exception names:
if(error.name === 'SomeServiceException') {
const value = error.specialKeyInException;
}
*/
}
Getting Help
Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them.
- Ask a question on StackOverflow and tag it with
aws-sdk-js
- Come join the AWS JavaScript community on gitter
- If it turns out that you may have found a bug, please open an issue
Contributing
This client code is generated automatically. Any modifications will be overwritten the next time the `@aws-sdk/@aws-sdk/client-glacier-browser' package is updated. To contribute to SDK you can checkout our code generator package.
License
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.