Bloom.WebLibraryIntegration.BloomS3Client.DownloadFile C# (CSharp) Method

DownloadFile() public method

public DownloadFile ( string bucketName, string storageKeyOfFile ) : string
bucketName string
storageKeyOfFile string
return string
        public string DownloadFile(string bucketName, string storageKeyOfFile)
        {
            var request = new GetObjectRequest() {BucketName = bucketName, Key = storageKeyOfFile};
            using (var response = GetAmazonS3(bucketName).GetObject(request))
            using (var stream = response.ResponseStream)
            using (var reader = new StreamReader(stream, Encoding.UTF8))
            {
                return reader.ReadToEnd();
            }
        }

Usage Example

Example #1
0
        internal bool CheckAgainstHashFileOnS3(string currentHashes, string bookFolder, IProgress progress)
        {
            string hashInfoOnS3 = null;

            try
            {
                if (!IsBookOnServer(bookFolder))
                {
                    return(false);
                }
                var bkInfo = new BookInfo(bookFolder, true);
                var s3id   = S3BookId(bkInfo.MetaData);
                var key    = s3id + BloomS3Client.kDirectoryDelimeterForS3 + Path.GetFileName(bookFolder) + BloomS3Client.kDirectoryDelimeterForS3 + UploadHashesFilename;
                hashInfoOnS3 = _s3Client.DownloadFile(UseSandbox ? BloomS3Client.SandboxBucketName : BloomS3Client.ProductionBucketName, key);
            }
            catch
            {
                hashInfoOnS3 = "";                      // probably file doesn't exist because it hasn't yet been uploaded
            }

#if DEBUG
            if (currentHashes != hashInfoOnS3)
            {
                progress.WriteMessage("local hash");
                progress.WriteMessage(currentHashes);
                progress.WriteMessage("s3 hash");
                progress.WriteMessage(hashInfoOnS3);
            }
#endif
            return(currentHashes == hashInfoOnS3);
        }
All Usage Examples Of Bloom.WebLibraryIntegration.BloomS3Client::DownloadFile