public static async Task <Stream> ReadBinary( IAmazonS3 _s3Client, string _bucketName, string _databaseName, string _collectionName, string _id) { string key = S3NamingHelper.GetBinaryFile(_databaseName, _collectionName, _id); GetObjectRequest request = new GetObjectRequest() { BucketName = _bucketName, Key = key }; GetObjectResponse response = await _s3Client.GetObjectAsync(request); return(response.ResponseStream); }
public static void WriteBinary( IAmazonS3 _s3Client, string _bucketName, string _databaseName, string _collectionName, string _id, string _contentType, Stream _dataStream) { string key = S3NamingHelper.GetBinaryFile(_databaseName, _collectionName, _id); PutObjectRequest request = new PutObjectRequest() { BucketName = _bucketName, Key = key, ContentType = _contentType, InputStream = _dataStream }; Task <PutObjectResponse> task = _s3Client.PutObjectAsync(request); Task.WaitAll(task); }