C# Class Bloom.WebLibraryIntegration.BloomS3Client

Handles Bloom file/folder operations on Amazon Web Services S3 service.
Inheritance: IDisposable
Show file Open project: BloomBooks/BloomDesktop Class Usage Examples

Public Methods

Method Description
BloomS3Client ( string bucketName ) : System
DeleteBookData ( string bucketName, string key ) : void
Dispose ( ) : void
DownloadBook ( string bucketName, string storageKeyOfBookFolder, string pathToDestinationParentDirectory, IProgressDialog downloadProgress = null ) : string

Warning, if the book already exists in the location, this is going to delete it an over-write it. So it's up to the caller to check the sanity of that.

DownloadFile ( string bucketName, string storageKeyOfFile ) : string
EmptyUnitTestBucket ( string prefix ) : void
UploadBook ( string storageKeyOfBookFolder, string pathToBloomBookDirectory, IProgress progress, string pdfToInclude = null ) : void

The thing here is that we need to guarantee unique names at the top level, so we wrap the books inside a folder with some unique name. As this involves copying the folder it is also a convenient place to omit any PDF files except the one we want.

UploadSingleFile ( string pathToFile, IProgress progress ) : string

Allows a file to be put into the root of the bucket. Could be enhanced to specify a sub folder path, but I don't need that for the current use.

Private Methods

Method Description
AvoidThisFile ( string objectKey ) : bool
CopyDirectory ( string sourceDirName, string destDirName ) : bool

copy directory and all subdirectories

CountDesiredFiles ( Amazon.S3.Model.ListObjectsResponse matching ) : int
DeleteFileSystemInfo ( FileSystemInfo fileSystemInfo ) : void
GetAmazonS3 ( string bucketName ) : IAmazonS3
GetBookFileCount ( string key, string bucketName ) : int
GetMatchingItems ( string bucketName, string key ) : Amazon.S3.Model.ListObjectsResponse
SameFileContent ( string path1, string path2 ) : bool
UploadDirectory ( string prefix, string directoryPath, IProgress progress ) : void

THe weird thing here is that S3 doesn't really have folders, but you can give it a key like "collection/book2/file3.htm" and it will name it that, and gui client apps then treat that like a folder structure, so you feel like there are folders.

Method Details

BloomS3Client() public method

public BloomS3Client ( string bucketName ) : System
bucketName string
return System

DeleteBookData() public method

public DeleteBookData ( string bucketName, string key ) : void
bucketName string
key string
return void

Dispose() public method

public Dispose ( ) : void
return void

DownloadBook() public method

Warning, if the book already exists in the location, this is going to delete it an over-write it. So it's up to the caller to check the sanity of that.
public DownloadBook ( string bucketName, string storageKeyOfBookFolder, string pathToDestinationParentDirectory, IProgressDialog downloadProgress = null ) : string
bucketName string
storageKeyOfBookFolder string
pathToDestinationParentDirectory string
downloadProgress IProgressDialog
return string

DownloadFile() public method

public DownloadFile ( string bucketName, string storageKeyOfFile ) : string
bucketName string
storageKeyOfFile string
return string

EmptyUnitTestBucket() public method

public EmptyUnitTestBucket ( string prefix ) : void
prefix string
return void

UploadBook() public method

The thing here is that we need to guarantee unique names at the top level, so we wrap the books inside a folder with some unique name. As this involves copying the folder it is also a convenient place to omit any PDF files except the one we want.
public UploadBook ( string storageKeyOfBookFolder, string pathToBloomBookDirectory, IProgress progress, string pdfToInclude = null ) : void
storageKeyOfBookFolder string
pathToBloomBookDirectory string
progress IProgress
pdfToInclude string
return void

UploadSingleFile() public method

Allows a file to be put into the root of the bucket. Could be enhanced to specify a sub folder path, but I don't need that for the current use.
public UploadSingleFile ( string pathToFile, IProgress progress ) : string
pathToFile string
progress IProgress
return string