Bloom.WebLibraryIntegration.BookTransfer.HandleDownloadWithoutProgress C# (CSharp) Method

HandleDownloadWithoutProgress() private method

url is typically something like https://s3.amazonaws.com/BloomLibraryBooks/[email protected]/0a2745dd-ca98-47ea-8ba4-2cabc67022e It is harmless if there are more elements in it (e.g. address to a particular file in the folder) Note: if you copy the url from part of the link to a file in the folder from AWS, you typically need to change %40 to @ in the uploader's email.
private HandleDownloadWithoutProgress ( string url, string destRoot ) : string
url string
destRoot string
return string
        internal string HandleDownloadWithoutProgress(string url, string destRoot)
        {
            _progressDialog = new ConsoleProgress();
            if (!url.StartsWith(BloomS3UrlPrefix))
            {
                Console.WriteLine("Url unexpectedly does not start with https://s3.amazonaws.com/");
                return "";
            }
            var bookOrder = url.Substring(BloomS3UrlPrefix.Length);
            var index = bookOrder.IndexOf('/');
            var bucket = bookOrder.Substring(0, index);
            var folder = bookOrder.Substring(index + 1);

            return DownloadBook(bucket, folder, destRoot);
        }

Usage Example

 public static int HandleSilentDownload(DownloadBookOptions options)
 {
     // This task will be all the program does. We need to do enough setup so that
     // the download code can work, then tear it down.
     Program.SetUpErrorHandling();
     try
     {
         using (var applicationContainer = new ApplicationContainer())
         {
             Program.SetUpLocalization(applicationContainer);
             Browser.SetUpXulRunner();
             Browser.XulRunnerShutdown += Program.OnXulRunnerShutdown;
             LocalizationManager.SetUILanguage(Settings.Default.UserInterfaceLanguage, false);
             var transfer = new BookTransfer(new BloomParseClient(), ProjectContext.CreateBloomS3Client(),
                 applicationContainer.BookThumbNailer, new BookDownloadStartingEvent()) /*not hooked to anything*/;
             // Since Bloom is not a normal console app, when run from a command line, the new command prompt
             // appears at once. The extra newlines here are attempting to separate this from our output.
             Console.WriteLine("\nstarting download");
             transfer.HandleDownloadWithoutProgress(options.Url, options.DestinationPath);
             Console.WriteLine(("\ndownload complete\n"));
         }
         return 0;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
         return 1;
     }
 }