public DownloadBook ( string bucketName, string storageKeyOfBookFolder, string pathToDestinationParentDirectory, IProgressDialog downloadProgress = null ) : string | ||
bucketName | string | |
storageKeyOfBookFolder | string | |
pathToDestinationParentDirectory | string | |
downloadProgress | IProgressDialog | |
리턴 | string |
/// <summary> /// Internal for testing because it's not yet clear this is the appropriate public routine. /// Probably some API gets a list of BloomInfo objects from the parse.com data, and we pass one of /// them as the argument for the public method. /// </summary> /// <param name="bucket"></param> /// <param name="s3BookId"></param> /// <param name="dest"></param> /// <returns></returns> internal string DownloadBook(string bucket, string s3BookId, string dest) { var destinationPath = _s3Client.DownloadBook(bucket, s3BookId, dest, _progressDialog); if (BookDownLoaded != null) { var bookInfo = new BookInfo(destinationPath, false); // A downloaded book is a template, so never editable. BookDownLoaded(this, new BookDownloadedEventArgs() { BookDetails = bookInfo }); } // Books in the library should generally show as locked-down, so new users are automatically in localization mode. // Occasionally we may want to upload a new authoring template, that is, a 'book' that is suitableForMakingShells. // Such books should not be locked down. // So, we try to lock it. What we want to do is Book.RecordedAsLockedDown = true; Book.Save(). // But all kinds of things have to be set up before we can create a Book. So we duplicate a few bits of code. var htmlFile = BookStorage.FindBookHtmlInFolder(destinationPath); if (htmlFile == "") { return(destinationPath); //argh! we can't lock it. } var xmlDomFromHtmlFile = XmlHtmlConverter.GetXmlDomFromHtmlFile(htmlFile, false); var dom = new HtmlDom(xmlDomFromHtmlFile); if (!BookMetaData.FromString(MetaDataText(destinationPath)).IsSuitableForMakingShells) { dom.RecordAsLockedDown(true); XmlHtmlConverter.SaveDOMAsHtml5(dom.RawDom, htmlFile); } return(destinationPath); }
/// <summary> /// Internal for testing because it's not yet clear this is the appropriate public routine. /// Probably some API gets a list of BloomInfo objects from the parse.com data, and we pass one of /// them as the argument for the public method. /// </summary> /// <param name="s3BookId"></param> /// <param name="dest"></param> /// <returns></returns> internal string DownloadBook(string s3BookId, string dest) { var destinationPath = _s3Client.DownloadBook(s3BookId, dest, _progressDialog); if (BookDownLoaded != null) { var bookInfo = new BookInfo(destinationPath, false); // A downloaded book is a template, so never editable. BookDownLoaded(this, new BookDownloadedEventArgs() { BookDetails = bookInfo }); } return(destinationPath); }
/// <summary> /// Internal for testing because it's not yet clear this is the appropriate public routine. /// Probably some API gets a list of BloomInfo objects from the parse.com data, and we pass one of /// them as the argument for the public method. /// </summary> /// <param name="bucket"></param> /// <param name="s3BookId"></param> /// <param name="dest"></param> /// <returns></returns> internal string DownloadBook(string bucket, string s3BookId, string dest) { var destinationPath = _s3Client.DownloadBook(bucket, s3BookId, dest, _progressDialog); if (BookDownLoaded != null) { var bookInfo = new BookInfo(destinationPath, false); // A downloaded book is a template, so never editable. BookDownLoaded(this, new BookDownloadedEventArgs() { BookDetails = bookInfo }); } // Books in the library should generally show as locked-down, so new users are automatically in localization mode. // Occasionally we may want to upload a new authoring template, that is, a 'book' that is suitableForMakingShells. // Such books should not be locked down. // So, we try to lock it. What we want to do is Book.RecordedAsLockedDown = true; Book.Save(). // But all kinds of things have to be set up before we can create a Book. So we duplicate a few bits of code. var htmlFile = BookStorage.FindBookHtmlInFolder(destinationPath); if (htmlFile == "") { return(destinationPath); //argh! we can't lock it. } var xmlDomFromHtmlFile = XmlHtmlConverter.GetXmlDomFromHtmlFile(htmlFile, false); var dom = new HtmlDom(xmlDomFromHtmlFile); bool needToSave = false; // If the book is downloaded from Bloom Library, we don't want to treat it as though // it were directly created from a Reader bloomPack. So relax the formatting lock. // See https://issues.bloomlibrary.org/youtrack/issue/BL-9996. if (dom.HasMetaElement("lockFormatting")) { dom.RemoveMetaElement("lockFormatting"); needToSave = true; } if (!BookMetaData.FromString(MetaDataText(destinationPath)).IsSuitableForMakingShells) { dom.RecordAsLockedDown(true); needToSave = true; } if (needToSave) { XmlHtmlConverter.SaveDOMAsHtml5(dom.RawDom, htmlFile); } return(destinationPath); }
static int Main(string[] arguments) { if (arguments.Length != 1) { Console.WriteLine("Usage: BloomBookDownloader keyOnAmazonS3"); return 1; } var t = new BloomS3Client(BloomS3Client.SandboxBucketName); var destinationPath = Path.Combine(Path.GetTempPath(), "BloomBookDownloader"); if (!Directory.Exists(destinationPath)) { Directory.CreateDirectory(destinationPath); } t.DownloadBook(arguments[0], destinationPath); return 0; }