

 **此頁面僅適用於使用 Vaults 和 2012 年原始 REST API 的 Amazon Glacier 服務的現有客戶。**

如果您要尋找封存儲存解決方案，建議您在 Amazon Glacier Instant Retrieval、S3 Glacier Flexible Retrieval 和 S3 Glacier Deep Archive 中使用 Amazon Glacier 儲存類別。 Amazon S3 若要進一步了解這些儲存選項，請參閱 [Amazon Glacier 儲存類別](https://aws.amazon.com/s3/storage-classes/glacier/)。

Amazon Glacier （原始獨立保存庫型服務） 不再接受新客戶。Amazon Glacier 是一項獨立服務，具有自己的 APIs，可將資料存放在保存庫中，並與 Amazon S3 和 Amazon S3 Glacier 儲存類別不同。您現有的資料將在 Amazon Glacier 中無限期保持安全且可存取。不需要遷移。對於低成本、長期的封存儲存， AWS 建議使用 [Amazon S3 Glacier 儲存類別](https://aws.amazon.com/s3/storage-classes/glacier/)，透過 S3 儲存貯體型 APIs、完整 AWS 區域 可用性、降低成本 AWS 和服務整合，提供卓越的客戶體驗。如果您想要增強功能，請考慮使用我們的解決方案指南，將資料從 Amazon S3 Glacier 保存庫傳輸至 Amazon S3 Glacier 儲存類別，以遷移至 Amazon S3 Glacier 儲存類別。 [AWS Amazon Glacier Amazon S3 ](https://aws.amazon.com/solutions/guidance/data-transfer-from-amazon-s3-glacier-vaults-to-amazon-s3/)

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 步驟 4：從 Amazon Glacier 中的保存庫下載封存
<a name="getting-started-download-archive"></a>

在此步驟中，您將下載之前在 [步驟 3：將封存上傳至 Amazon Glacier 中的保存庫](getting-started-upload-archive.md) 中上傳的範例封存。

 

**重要**  
Amazon Glacier 會提供主控台。不過，上傳、下載或刪除等任何封存操作都需要您使用 AWS Command Line Interface (CLI) 或寫入程式碼。沒有主控台支援封存操作。例如，若要上傳資料，例如相片、影片和其他文件，您必須使用 AWS CLI 或編寫程式碼來提出請求，方法是直接使用 REST API 或使用 AWS SDKs。  
若要安裝 AWS CLI，請參閱 [AWS Command Line Interface](https://aws.amazon.com/cli/)。如需搭配 使用 Amazon Glacier 的詳細資訊 AWS CLI，請參閱 [AWS CLI Amazon Glacier 的參考](https://docs.aws.amazon.com/cli/latest/reference/glacier/index.html)。如需使用 AWS CLI 將封存上傳至 Amazon Glacier 的範例，請參閱[搭配使用 Amazon Glacier 與 AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-using-glacier.html)。

一般而言，從 Amazon Glacier 擷取您的資料需要兩個步驟：

1. 啟動擷取任務。

1. 工作完成後，下載資料的位元組。

若要從 Amazon Glacier 擷取封存，您必須先啟動任務。在工作完成後下載資料。如需封存擷取的詳細資訊，請參閱 [擷取 Amazon Glacier Archives](downloading-an-archive-two-steps.md)。

請求的存取時間取決於您選擇的擷取選項：快速、標準或大量擷取。用於規模幾乎最大的封存 (250 MB 以上) 時，使用快速擷取所存取的資料，通常會在 1-5 分鐘內即可使用。使用標準擷取而擷取的封存通常在 3-5 小時之間即可使用。大量擷取通常會於 5-12 小時內即可使用。如需各種擷取選項的詳細資訊，請參閱 [Amazon Glacier 常見問答集](https://aws.amazon.com/glacier/faqs/#Data-retrievals)。如需資料擷取費用的資訊，請參閱 [Amazon Glacier 定價頁面](https://aws.amazon.com/s3/glacier/pricing/)。

下列主題中顯示的程式碼範例啟動工作，請等待其完成，然後下載封存的資料。

**Topics**
+ [使用 從 Amazon Glacier 中的保存庫下載封存 適用於 Java 的 AWS SDK](getting-started-download-archive-java.md)
+ [使用 從 Amazon Glacier 中的保存庫下載封存 適用於 .NET 的 AWS SDK](getting-started-download-archive-dotnet.md)

# 使用 從 Amazon Glacier 中的保存庫下載封存 適用於 Java 的 AWS SDK
<a name="getting-started-download-archive-java"></a>

下列 Java 程式碼範例使用 的高階 API 適用於 Java 的 AWS SDK 來下載您在上一個步驟中上傳的封存。在程式碼範例中，請注意下列事項：
+ 範例會建立 `AmazonGlacierClient` 類別的執行個體。
+ 此程式碼使用美國西部 (奧勒岡) 區域 (`us-west-2`) 比對在 [步驟 2：在 Amazon Glacier 中建立保存庫](getting-started-create-vault.md) 中建立保存庫的位置。
+ 此範例使用 適用於 Java 的 AWS SDK高階 API 的 `ArchiveTransferManager` 類別的 `download` API 作業。此範例會建立 Amazon Simple Notification Service (Amazon SNS) 主題，以及訂閱該主題的 Amazon Simple Queue Service (Amazon SQS) 佇列。如果您依照 中的指示建立 AWS Identity and Access Management (IAM) 管理員使用者[步驟 1：開始使用 Amazon Glacier 之前](getting-started-before-you-begin.md)，則您的使用者具有建立和使用 Amazon SNS 主題和 Amazon SQS 佇列的必要 IAM 許可。

如需執行此範例的逐步說明，請參閱 [使用 Eclipse 執行 Amazon Glacier 的 Java 範例](using-aws-sdk-for-java.md#setting-up-and-testing-sdk-java)。您需要按照在 [步驟 3：將封存上傳至 Amazon Glacier 中的保存庫](getting-started-upload-archive.md) 中上傳之檔案的封存 ID 來更新程式碼。

**Example — 使用 下載封存 適用於 Java 的 AWS SDK**  <a name="GS_ExampleDownloadArchiveJava"></a>

```
import java.io.File;
import java.io.IOException;

import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.glacier.AmazonGlacierClient;
import com.amazonaws.services.glacier.transfer.ArchiveTransferManager;
import com.amazonaws.services.sns.AmazonSNSClient;
import com.amazonaws.services.sqs.AmazonSQSClient;

public class AmazonGlacierDownloadArchive_GettingStarted {
    public static String vaultName = "examplevault";
    public static String archiveId = "*** provide archive ID ***";
    public static String downloadFilePath  = "*** provide location to download archive ***";
    
    public static AmazonGlacierClient glacierClient;
    public static AmazonSQSClient sqsClient;
    public static AmazonSNSClient snsClient;
    
    public static void main(String[] args) throws IOException {
        
        
    	ProfileCredentialsProvider credentials = new ProfileCredentialsProvider();
    	
        glacierClient = new AmazonGlacierClient(credentials);        
        sqsClient = new AmazonSQSClient(credentials);
        snsClient = new AmazonSNSClient(credentials);
        
        glacierClient.setEndpoint("glacier.us-west-2.amazonaws.com");
        sqsClient.setEndpoint("sqs.us-west-2.amazonaws.com");
        snsClient.setEndpoint("sns.us-west-2.amazonaws.com");

        try {
            ArchiveTransferManager atm = new ArchiveTransferManager(glacierClient, sqsClient, snsClient);
            
            atm.download(vaultName, archiveId, new File(downloadFilePath));
            
        } catch (Exception e)
        {
            System.err.println(e);
        }
    }
}
```

# 使用 從 Amazon Glacier 中的保存庫下載封存 適用於 .NET 的 AWS SDK
<a name="getting-started-download-archive-dotnet"></a>

下列 C\$1 程式碼範例使用 的高階 API 適用於 .NET 的 AWS SDK 來下載您先前在 中上傳的封存[使用 將封存上傳至 Amazon Glacier 中的保存庫 適用於 .NET 的 AWS SDK](getting-started-upload-archive-dotnet.md)。在程式碼範例中，請注意下列事項：

 
+ 此範例會為指定的 Amazon Glacier 區域端點建立 `ArchiveTransferManager`類別的執行個體。
+ 此程式碼範例使用美國西部 (奧勒岡) 區域 (`us-west-2`)，比對之前在 [步驟 2：在 Amazon Glacier 中建立保存庫](getting-started-create-vault.md) 中建立保存庫的位置。
+ 本範例使用 `ArchiveTransferManager` 類別的 `Download` API 作業以下載封存。此範例會建立 Amazon Simple Notification Service (Amazon SNS) 主題，以及訂閱該主題的 Amazon Simple Queue Service (Amazon SQS) 佇列。如果您依照 中的指示建立 AWS Identity and Access Management (IAM) 管理員使用者[步驟 1：開始使用 Amazon Glacier 之前](getting-started-before-you-begin.md)，則您的使用者具有建立和使用 Amazon SNS 主題和 Amazon SQS 佇列的必要 IAM 許可。
+ 此範例接著啟動封存擷取任務，輪詢佇列以使封存可用。封存可用時，就會開始下載。如需封存擷取時間的詳細資訊，請參閱 [封存擷取選項](downloading-an-archive-two-steps.md#api-downloading-an-archive-two-steps-retrieval-options)。

如需執行此範例的逐步說明，請參閱 [執行程式碼範例](using-aws-sdk-for-dot-net.md#setting-up-and-testing-sdk-dotnet)。您需要按照在 [步驟 3：將封存上傳至 Amazon Glacier 中的保存庫](getting-started-upload-archive.md) 中上傳之檔案的封存 ID 來更新程式碼。

**Example — 使用 的高階 API 下載封存 適用於 .NET 的 AWS SDK**  <a name="GS_ExampleDownloadArchiveDotNet"></a>

```
using System;
using Amazon.Glacier;
using Amazon.Glacier.Transfer;
using Amazon.Runtime;

namespace glacier.amazon.com.rproxy.govskope.us.docsamples
{
    class ArchiveDownloadHighLevel_GettingStarted
    {
        static string vaultName = "examplevault";
        static string archiveId = "*** Provide archive ID ***";
        static string downloadFilePath = "*** Provide the file name and path to where to store the download ***";

        public static void Main(string[] args)
        {
            try
            {
                var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USWest2);

                var options = new DownloadOptions();
                options.StreamTransferProgress += ArchiveDownloadHighLevel_GettingStarted.progress;
                // Download an archive.
                Console.WriteLine("Intiating the archive retrieval job and then polling SQS queue for the archive to be available.");
                Console.WriteLine("Once the archive is available, downloading will begin.");
                manager.Download(vaultName, archiveId, downloadFilePath, options);
                Console.WriteLine("To continue, press Enter");
                Console.ReadKey();
            }
            catch (AmazonGlacierException e) { Console.WriteLine(e.Message); }
            catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
            catch (Exception e) { Console.WriteLine(e.Message); }
            Console.WriteLine("To continue, press Enter");
            Console.ReadKey();
        }

        static int currentPercentage = -1;
        static void progress(object sender, StreamTransferProgressArgs args)
        {
            if (args.PercentDone != currentPercentage)
            {
                currentPercentage = args.PercentDone;
                Console.WriteLine("Downloaded {0}%", args.PercentDone);
            }
        }
    }
}
```