Пример #1
0
        public void runDownload()
        {
            try
            {
                //var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USWest2);

                //var options = new DownloadOptions();
                //options.StreamTransferProgress += ArchiveDownloadHighLevel.progress;
                //// Download an archive.
                //Console.WriteLine("Intiating the archive retrieval job and then polling SQS queue for the archive to be available.");
                //Console.WriteLine("This polling takes about 4 hours. Once the archive is available, downloading will begin.");
                //manager.Download(vaultName, archiveId, downloadFilePath, options);
                //Console.WriteLine("To continue, press Enter");
                //Console.ReadKey();

                var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USEast1);
                var options = new DownloadOptions();
                options.StreamTransferProgress += DownloadFile.progress;
                Console.WriteLine("Intiating the archive retrieval job and then polling SQS queue for the archive to be available.");
                Console.WriteLine("This polling takes about 4 hours. Once the archive is available, downloading will begin.");
                manager.Download(vaultName, archiveToDownload, downloadFilePath, options);
                manager.Download(vaultName, archiveToDownload2, downloadFilePath2, 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();
        }
Пример #2
0
        public void DownloadGlacier()
        {
            var archiveId        = "SOUSY3B601HbkJSiFdrzvE3CUDHuLHaoxbKwbIiSIdIuQTjcTw_XXm0i38HGLaJhubxRrTdvY-5UjYsSLWK0PVMcG5Mf9LKd9oBPAuwNIzGGhZmZ7zF9DaQU6lDuPh2C_4ViIc5dlw";
            var settings         = SettingsManager.GetSettings();
            var downloadFilePath = @"C:\Users\Rob\source\repos\Backup\archive\glacier.zip";

            try
            {
                var manager = new ArchiveTransferManager(
                    settings.AWSAccessKeyID,
                    settings.AWSSecretAccessKey,
                    RegionEndpoint.GetBySystemName(settings.AWSS3Region.SystemName));

                var options = new DownloadOptions();
                options.StreamTransferProgress += AWSGlacierClient.Progress;

                // High-level method to download an archive.
                // Intiating the archive retrieval job and then polling SQS queue for the archive to be available
                // This polling takes about 4 hours. Once the archive is available, downloading will begin.
                manager.Download(settings.AWSGlacierVault, archiveId, downloadFilePath, options);
            }
            catch (AmazonGlacierException e) { Debug.WriteLine(e.Message); throw e; }
            catch (AmazonServiceException e) { Debug.WriteLine(e.Message); throw e; }
            catch (Exception e) { Debug.WriteLine(e.Message); throw e; }
        }
Пример #3
0
        public void DownloadArchive()
        {
            var manager = new ArchiveTransferManager(credentials, Amazon.RegionEndpoint.USWest1);

            manager.Download(vaultName, "Fwu7VQI4XKOgZkf-TzQxZeiGkB4Ker1T2P79gYwMYzRnyQaYSNC_JyKlYs99ITvFOJrqAFy1iaW8tQIZGsekEbBdyKhQ1d32vOtFraaN5u7sYXYnCGsWNZ4OC7FVWw_HHxg50TkTfA", AppDomain.CurrentDomain.BaseDirectory + "\\test-galcier.txt");
            Console.WriteLine("File downloaded successfully!");
        }
Пример #4
0
        public static AWSArchiveResult DownloadFile(AWSArchiveRquest request)
        {
            using (manager = new ArchiveTransferManager(RegionEndpoint.USEast1))
            {
                if (CheckRequiredFields())
                {
                    try
                    {
                        Form1.log.Info("Download a Archive");

                        try
                        {
                            var options = new DownloadOptions();
                            options.StreamTransferProgress += AWSMoveFilesXDynamo.OnProgress;

                            // Download an archive.
                            manager.Download(vaultName, request.ArchiveID, request.Description, options);
                        }
                        catch (AmazonGlacierException e) { Form1.log.Error(e.Message); }
                        catch (AmazonServiceException e) { Form1.log.Error(e.Message); }
                        catch (Exception e) { Form1.log.Error(e.Message); }
                    }
                    catch (AmazonGlacierException e)
                    {
                        Form1.log.Error(e.Message);
                    }
                    catch (AmazonServiceException e)
                    {
                        Form1.log.Error(e.Message);
                    }
                }
                return(new AWSArchiveResult());
            }
        }
Пример #5
0
        public void DownloadArchive()
        {
            var manager = new ArchiveTransferManager(credentials, Amazon.RegionEndpoint.USWest1);

            manager.Download(vaultName,
                             "bIN_WObb6J9b_EkKN-G0nOXn1bf6J0JJM573ZbFg8K5KuuWsZDgmGBylHg_MiIaB3My-d1n5qtW_AsMgZgVg6FOzPjgeKbu1RX2jrkUi2kpH0SJ5xhkgjXz-XgWYS3OVqq5hxN_Ftw",
                             AppDomain.CurrentDomain.BaseDirectory + "\\test-galcier.txt");
            Console.WriteLine("File downloaded successfully");
        }
Пример #6
0
        public static void DownloadArchive(string vaultName, string archiveId, string outputPath, Amazon.RegionEndpoint awsRegion)
        {
            Logger.LogMessage($"Downloading archive '{archiveId}' from {vaultName}...");
            using (var manager = new ArchiveTransferManager(awsRegion))
            {
                var downloadOptions = new DownloadOptions()
                {
                    PollingInterval = 1.0
                };
                downloadOptions.StreamTransferProgress += OnTransferProgress;

                manager.Download(vaultName, archiveId, outputPath, downloadOptions);
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            if (CheckRequiredFields())
            {
                using (manager = new ArchiveTransferManager(RegionEndpoint.USWest2))
                {
                    try
                    {
                        // Creates a new Vault
                        Console.WriteLine("Create Vault");
                        manager.CreateVault(vaultName);

                        // Uploads the specified file to Glacier.
                        Console.WriteLine("Upload a Archive");
                        var uploadResult = manager.Upload(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;
                        manager.Download(vaultName, archiveId, downloadFilePath, options);

                        Console.WriteLine("Delete the Archive");
                        manager.DeleteArchive(vaultName, archiveId);
                    }
                    catch (AmazonGlacierException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    catch (AmazonServiceException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }
        }
Пример #8
0
        public AWSArchiveResult DownloadFile(AWSArchiveRquest request)
        {
            archiveRequest = request;

            using (manager = new ArchiveTransferManager(RegionEndpoint.USEast1))
            {
                if (CheckRequiredFields())
                {
                    try
                    {
                        Form1.log.Info("Download  Archive" + request.ArchiveID + " " + request.Description + " " + request.FileName);

                        try
                        {
                            var options = new DownloadOptions();
                            options.StreamTransferProgress += OnProgress;

                            // Download an archive.
                            manager.Download(vaultName, request.ArchiveID, request.Description, options);

                            if (request.Description.Contains(".tif"))
                            {
                                String outfileName = String.Empty;

                                String fileName = request.Description;

                                FileInfo fi = new FileInfo(fileName);

                                fi.MoveTo(fileName + ".z");

                                fileName = fileName + ".z";

                                outfileName = fileName.Replace(".z", "");

                                FileStream inputFile   = File.Open(fileName, FileMode.Open, FileAccess.Read);
                                byte[]     treeHash    = Form1.ComputeSHA256TreeHash(inputFile);
                                String     zipChecksum = BitConverter.ToString(treeHash).Replace("-", "").ToLower();

                                Form1.log.Info(fileName + "  Tree SHA 256 Checksum : " + zipChecksum);

                                Form1.log.Info(fileName + "  Original Injection Tree SHA 256 Checksum : " + request.ChecksumTreeSHA256Compressed);

                                ParallelCompress.doNotUseTPL = false;

                                ParallelCompress.compressStrictSeqential = false;

                                ParallelCompress.UncompressFast(outfileName, fileName, true);

                                inputFile = File.Open(outfileName, FileMode.Open, FileAccess.Read);
                                treeHash  = Form1.ComputeSHA256TreeHash(inputFile);
                                String decompressedChecksum = BitConverter.ToString(treeHash).Replace("-", "").ToLower();

                                Form1.log.Info(outfileName + "  Decmpressed Tree SHA 256 Checksum : " + zipChecksum);

                                Form1.log.Info(outfileName + "  Decmplressed Original Tree SHA 256 Checksum : " + request.ChecksumTreeSHA256Compressed);
                            }
                        }
                        catch (AmazonGlacierException e) { Form1.log.Error(e.ToString()); }
                        catch (AmazonServiceException e) { Form1.log.Error(e.ToString()); }
                        catch (Exception e) { Form1.log.Error(e.ToString()); }
                    }
                    catch (AmazonGlacierException e)
                    {
                        Form1.log.Error(e.ToString());
                    }
                    catch (AmazonServiceException e)
                    {
                        Form1.log.Error(e.ToString());
                    }
                }
                return(new AWSArchiveResult());
            }
        }
Пример #9
0
        //static string archiveToUpload = AppDomain.CurrentDomain.BaseDirectory+"\\test.txt";
        //public void UploadVaultObject2()
        //{
        //    try
        //    {
        //        var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.EUWest1);
        //        // Upload an archive.
        //        string archiveId = manager.Upload(vaultName, "getting started archive test", archiveToUpload).ArchiveId;
        //        Console.WriteLine("Copy and save the following Archive ID for the next step.");
        //        Console.WriteLine("Archive ID: {0}", archiveId);
        //        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();
        //}

        public void DownloadFile()
        {
            var manager = new ArchiveTransferManager(credentials, Amazon.RegionEndpoint.EUWest1);

            manager.Download(vaultName, "B_CIJkgZDfSRnIgLgsAJBTTRqyWqjMIx_A6n1taETlPWFJLxn4fqBfNc0QDUsfBt18xihbcRJmY8JOfG6Pdr7FK3NFjpe9KbS0h4jM09H89mkMWbDqyH0GN0ZEO-EN1zS4qQdRJYIw", AppDomain.CurrentDomain.BaseDirectory + "\\test-downloadGlacier.txt");
        }