C# Class Bloom.WebLibraryIntegration.BookTransfer

Currently pushes a book's metadata to Parse.com (a mongodb service) and files to Amazon S3. We are using both because Parse offers a more structured, query-able data organization that is useful for metadata, but does not allow large enough files for some of what we need.
Show file Open project: BloomBooks/BloomDesktop Class Usage Examples

Private Properties

Property Type Description
BackgroundUpload void
DisplayNetworkUploadProblem void
DisplayProblem void
DownloadBook string
FullUpload string
GetUrlAndTitle void
HandleBloomBookOrder void
HandleBookOrder void
HandleDownloadWithoutProgress string
IsThisVersionAllowedToUpload bool
IsUrlOrder bool
MetaDataText string
OnDoDownload void
S3BookId string
UploadInternal void
UploadPdfPath string
WaitUntilS3DataIsOnServer void

Public Methods

Method Description
BookTransfer ( BloomParseClient bloomParseClient, BloomS3Client bloomS3Client, BookThumbNailer htmlThumbnailer, BookDownloadStartingEvent bookDownloadStartingEvent ) : System
DownloadFromOrderUrl ( string orderUrl, string destPath, string title = "unknown" ) : string

Download a book

HandleBookOrder ( string bookOrderPath, string projectPath ) : void
IsBookOnServer ( string bookPath ) : bool
LogIn ( string account, string password ) : bool
Logout ( ) : void
UploadBook ( string bookFolder, IProgress progress ) : string
UploadBook ( string bookFolder, IProgress progress, string &parseId, string pdfToInclude = null ) : string
UploadFolder ( string folder, ApplicationContainer container ) : void

Upload bloom books in the specified folder to the bloom library. Folders that contain exactly one .htm file are interpreted as books and uploaded. Other folders are searched recursively for children that appear to be bloom books. The parent folder of a bloom book is searched for a .bloomContainer file and, if one is found, the book is treated as part of that collection (e.g., for determining vernacular language). If no collection is found there it uses whatever collection was last open, or the current default.

Private Methods

Method Description
BackgroundUpload ( object sender, DoWorkEventArgs doWorkEventArgs ) : void

Worker function for a background thread task. See first lines for required args passed to RunWorkerAsync, which triggers this.

DisplayNetworkUploadProblem ( Exception e, IProgress progress ) : void
DisplayProblem ( Exception e, string message ) : void
DownloadBook ( string bucket, string s3BookId, string dest ) : string

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.

FullUpload ( Book book, SIL.Windows.Forms.Progress.LogBox progressBox, PublishView publishView, string languages, string &parseId, Form invokeTarget = null ) : string

Common routine used in normal upload and bulk upload.

GetUrlAndTitle ( string bucket, string s3orderKey, string &url, string &title ) : void
HandleBloomBookOrder ( string order ) : void
HandleBookOrder ( string bookOrderPath ) : void
HandleDownloadWithoutProgress ( string url, string destRoot ) : string

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.

IsThisVersionAllowedToUpload ( ) : bool
IsUrlOrder ( string argument ) : bool
MetaDataText ( string bookFolder ) : string
OnDoDownload ( object sender, DoWorkEventArgs args ) : void

this runs in a worker thread

S3BookId ( BookMetaData metadata ) : string
UploadInternal ( string folder, BulkUploadProgressDlg dlg, ApplicationContainer container, ProjectContext &context ) : void

Handles the recursion through directories: if a folder looks like a Bloom book upload it; otherwise, try its children. Invisible folders like .hg are ignored.

UploadPdfPath ( string bookFolder ) : string
WaitUntilS3DataIsOnServer ( string bucket, string bookPath ) : void

Method Details

BookTransfer() public method

public BookTransfer ( BloomParseClient bloomParseClient, BloomS3Client bloomS3Client, BookThumbNailer htmlThumbnailer, BookDownloadStartingEvent bookDownloadStartingEvent ) : System
bloomParseClient BloomParseClient
bloomS3Client BloomS3Client
htmlThumbnailer BookThumbNailer
bookDownloadStartingEvent BookDownloadStartingEvent
return System

DownloadFromOrderUrl() public method

Download a book
public DownloadFromOrderUrl ( string orderUrl, string destPath, string title = "unknown" ) : string
orderUrl string bloom://localhost/order?orderFile=BloomLibraryBooks-UnitTests/[email protected]/a211f07b-2c9f-4b97-b0b1-71eb24fdbed79887cda9_bb1d_4422_aa07_bc8c19285ca9/My Url Book/My Url Book.BloomBookOrder
destPath string
title string
return string

HandleBookOrder() public method

public HandleBookOrder ( string bookOrderPath, string projectPath ) : void
bookOrderPath string
projectPath string
return void

IsBookOnServer() public method

public IsBookOnServer ( string bookPath ) : bool
bookPath string
return bool

LogIn() public method

public LogIn ( string account, string password ) : bool
account string
password string
return bool

Logout() public method

public Logout ( ) : void
return void

UploadBook() public method

public UploadBook ( string bookFolder, IProgress progress ) : string
bookFolder string
progress IProgress
return string

UploadBook() public method

public UploadBook ( string bookFolder, IProgress progress, string &parseId, string pdfToInclude = null ) : string
bookFolder string
progress IProgress
parseId string
pdfToInclude string
return string

UploadFolder() public method

Upload bloom books in the specified folder to the bloom library. Folders that contain exactly one .htm file are interpreted as books and uploaded. Other folders are searched recursively for children that appear to be bloom books. The parent folder of a bloom book is searched for a .bloomContainer file and, if one is found, the book is treated as part of that collection (e.g., for determining vernacular language). If no collection is found there it uses whatever collection was last open, or the current default.
public UploadFolder ( string folder, ApplicationContainer container ) : void
folder string
container ApplicationContainer
return void