Esempio n. 1
0
        private void Delete(GlacierArchive archive)
        {
            var task = _manager.DeleteArchiveAsync(_name, archive.ID);

            task.Wait();
            if (task.IsCompletedSuccessfully)
            {
                _archives.Remove(archive);
                Save();
            }
        }
Esempio n. 2
0
        static async void MainAsync(string[] args)
        {
            if (CheckRequiredFields())
            {
                var glacierClient = new AmazonGlacierClient();
                using (manager = new ArchiveTransferManager(glacierClient))
                {
                    try
                    {
                        // Creates a new Vault
                        Console.WriteLine("Create Vault");
                        await manager.CreateVaultAsync(vaultName);

                        // Uploads the specified file to Glacier.
                        Console.WriteLine("Upload a Archive");
                        var uploadResult = await manager.UploadAsync(vaultName, "Archive Description", filePath);

                        archiveId = uploadResult.ArchiveId;
                        Console.WriteLine("Upload successful. Archive Id : {0}  Checksum : {1}",
                                          uploadResult.ArchiveId, uploadResult.Checksum);


                        // Downloads the file from Glacier
                        // This operation can take a long time to complete.
                        // The ArchiveTransferManager.Download() method creates an Amazon SNS topic,
                        // and an Amazon SQS queue that is subscribed to that topic.
                        // It then initiates the archive retrieval job and polls the queue for the
                        // archive to be available. This polling takes about 4 hours.
                        // Once the archive is available, download will begin.
                        Console.WriteLine("Download the Archive");
                        var options = new DownloadOptions();
                        options.StreamTransferProgress += OnProgress;
                        await manager.DownloadAsync(vaultName, archiveId, downloadFilePath, options);

                        Console.WriteLine("Delete the Archive");
                        await manager.DeleteArchiveAsync(vaultName, archiveId);
                    }
                    catch (AmazonGlacierException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    catch (AmazonServiceException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }
        }
Esempio n. 3
0
        public static async Task DeleteArchiveAsync(string vaultName)
        {
            JObject archiveList = JObject.Parse(File.ReadAllText(@"archiveList.json"));

            try
            {
                var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.APSoutheast2);

                foreach (var archiveId in archiveList["ArchiveList"])
                {
                    await manager.DeleteArchiveAsync(vaultName, archiveId["ArchiveId"].ToString());

                    Console.WriteLine(archiveId["ArchiveId"]);
                }
            }
            catch (AmazonGlacierException e) { Console.WriteLine(e.Message); }
            catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
            catch (Exception e) { Console.WriteLine(e.Message); }
        }