AWS Glacier上传对象参考错误

时间:2018-09-18 08:51:43

标签: amazon-web-services amazon-glacier

我在Glacier中有如下代码,用于上传rar文件。我不知道自己缺少什么,有人可以发布示例代码将档案上传到AWS Glcier

private static ArchiveTransferManager manager;        
    private static int percentComplete;
    static string vaultName = "GlacierTest";
    static string archiveToUpload = @"vwTrunkIdentifierList.rar";
    static void Main(string[] args)
    {
        try
        {   
            using (manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USEast1))
            {
                UploadArchive(archiveToUpload);
            }
        }
        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.ReadLine();
    }

    private static void UploadArchive(string archiveToUpload)
    {
        percentComplete = 0;
        var uploadOptions = new UploadOptions();
        uploadOptions.StreamTransferProgress += new EventHandler<StreamTransferProgressArgs>(onStreamTransferProgress);
        var archive= manager.Upload(vaultName, "archive description", archiveToUpload);
        //var archive = manager.Upload(vaultName, "archive description", archiveToUpload, uploadOptions);

        //never gets here
        Console.WriteLine("ArchiveId: {0}, CheckSum: {1}", archive.ArchiveId, archive.Checksum);
    }

    private static void onStreamTransferProgress(object sender, StreamTransferProgressArgs args)
    {
        Console.WriteLine("Progress: {0} / {1} ({2}%)", args.TransferredBytes, args.TotalBytes, args.PercentDone);
        percentComplete = args.PercentDone;
    }

0 个答案:

没有答案