示例#1
0
        public static Stream ReadDocument(
            IAmazonS3 _s3Client,
            string _bucketName,
            string _databaseName,
            string _collectionName,
            string _id)
        {
            string key = S3NamingHelper.GetDocument(_databaseName, _collectionName, _id);

            GetObjectRequest request = new GetObjectRequest()
            {
                BucketName = _bucketName,
                Key        = key
            };

            Task <GetObjectResponse> task = _s3Client.GetObjectAsync(request);

            Task.WaitAll(task);

            return(task.Result.ResponseStream);
        }
示例#2
0
        public static void WriteDocument(
            IAmazonS3 _s3Client,
            string _bucketName,
            string _databaseName,
            string _collectionName,
            string _id,
            string _contentType,
            Stream _dataStream)
        {
            string key = S3NamingHelper.GetDocument(_databaseName, _collectionName, _id);

            PutObjectRequest request = new PutObjectRequest()
            {
                BucketName  = _bucketName,
                Key         = key,
                ContentType = _contentType,
                InputStream = _dataStream
            };

            Task <PutObjectResponse> task = _s3Client.PutObjectAsync(request);

            Task.WaitAll(task);
        }