Beispiel #1
0
        static void Main()
        {
            try
            {
                var manager = new ArchiveTransferManager(RegionEndpoint.USEast2);

                var options = new DownloadOptions
                {
                    StreamTransferProgress = 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.DownloadAsync(VaultName, ArchiveId, DownloadFilePath, options);
                Console.WriteLine("To continue, press Enter");
                Console.ReadKey();
            }
            catch (AmazonGlacierException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("To continue, press Enter");
            Console.ReadKey();
        }
Beispiel #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);
                    }
                }
            }
        }
Beispiel #3
0
        public async Task RunCode()
        {
            var client  = new AmazonGlacierClient();
            var manager = new ArchiveTransferManager(client);

            #region ArchiveTransferManager için kullanılan Kod Bloğu
            Console.Write("Yeni bir vault oluşturmak istiyor musunuz ?: [y/n] ");

            ConsoleKeyInfo decisionCreate = Console.ReadKey();
            Console.WriteLine();
            if (decisionCreate.Key == ConsoleKey.Y)
            {
                // High-Level API ile vault oluşturma işlemi
                Console.Write("Oluşturmak istediğiniz glacier vault ismini giriniz : ");
                var createVaultName = Console.ReadLine();
                await manager.CreateVaultAsync(createVaultName);

                Console.WriteLine($"{createVaultName} isimli vault oluşturuldu");
            }
            AddSpace();

            Console.Write("Bir vault içine upload yapmak istiyor musnuz ?: [y/n] ");

            ConsoleKeyInfo decisionUpload = Console.ReadKey();
            Console.WriteLine();
            if (decisionUpload.Key == ConsoleKey.Y)
            {
                // High-Level API ile archive oluşturma işlemi
                Console.Write("Upload yapmak istediğiniz glacier vault ismini giriniz : ");
                var uploadVaultName = Console.ReadLine();
                Console.Write("Oluşturmak istediğiniz archive  açıklamasını giriniz : ");
                var archiveDesc = Console.ReadLine();
                Console.Write("Upload etmek istediğiniz dosya yolunu giriniz : ");
                var filePath = Console.ReadLine();
                var response = await manager.UploadAsync(uploadVaultName, archiveDesc, filePath);

                Console.WriteLine($"Yüklemiş olduğunuz dosya kaydedilmiştir. ArchiveId : {response.ArchiveId} ");
            }
            AddSpace();

            Console.Write("Yeni bir download yapmak istiyor musunuz ?: [y/n] ");

            ConsoleKeyInfo decisionDownload = Console.ReadKey();
            Console.WriteLine();
            if (decisionDownload.Key == ConsoleKey.Y)
            {
                // High-Level API ile archive download etme işlemi
                Console.Write("Download yapmak istediğiniz glacier vault ismini giriniz : ");
                var downloadVaultName = Console.ReadLine();
                Console.Write("İndirmek istediğiniz archive için ArchiveId giriniz : ");
                var archiveId = Console.ReadLine();
                Console.Write("Download etmek istediğiniz local dosya yolunu giriniz : ");
                var downloadPath = Console.ReadLine();
                await manager.DownloadAsync(downloadVaultName, archiveId, downloadPath);

                Console.WriteLine($"Dosyanız başarılı şekilde indirildi.");
            }
            AddSpace();
            Console.Write("Bir vault Silmek istiyor musunuz ?: [y/n] ");

            ConsoleKeyInfo decisionDelete = Console.ReadKey();
            Console.WriteLine();
            if (decisionDelete.Key == ConsoleKey.Y)
            {
                // High-Level API ile vault silme işlemi
                Console.Write("Silmek istediğiniz glacier vault ismini giriniz : ");
                var deleteVaultName = Console.ReadLine();
                await manager.DeleteVaultAsync(deleteVaultName);

                Console.WriteLine($"{deleteVaultName} isimli vault başarı ile silindi.");
            }
            AddSpace();
            #endregion
        }