Ejemplo n.º 1
0
        /// <summary>
        ///     Returns a stream to read the contents from Amazon S3 as
        ///     specified by the <c>TransferUtilityOpenStreamRequest</c>.
        ///     The caller of this method is responsible for closing the stream.
        /// </summary>
        /// <param name="request">
        ///     Contains all the parameters required for the OpenStream operation.
        /// </param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public async Task <Stream> OpenStreamAsync(TransferUtilityOpenStreamRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            OpenStreamCommand command = new OpenStreamCommand(this._s3Client, request);
            await command.ExecuteAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);

            return(command.ResponseStream);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Returns a stream to read the contents from Amazon S3 as
        ///     specified by the <c>TransferUtilityOpenStreamRequest</c>.
        ///     The caller of this method is responsible for closing the stream.
        /// </summary>
        /// <param name="request">
        ///     Contains all the parameters required to open a stream to an S3 object.
        /// </param>
        /// <returns>
        ///     A stream of the contents from Amazon S3.
        /// </returns>
        public Stream OpenStream(TransferUtilityOpenStreamRequest request)
        {
            OpenStreamCommand command = new OpenStreamCommand(this._s3Client, request);

            command.Execute();
            return(command.ResponseStream);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initiates the asynchronous execution of the OpenStream operation.
        /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.Upload"/>
        /// </summary>
        /// <param name="bucketName">
        ///     The name of the bucket.
        /// </param>
        /// <param name="key">
        ///     The object key.
        /// </param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the AsyncState property.</param>
        /// <exception cref="T:System.ArgumentNullException"></exception>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both;
        /// this value is also needed when invoking EndOpenStream.</returns>
        public IAsyncResult BeginOpenStream(string bucketName, string key, AsyncCallback callback, object state)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
                                                       .WithBucketName(bucketName)
                                                       .WithKey(key);

            return(BeginOpenStream(request, callback, state));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Returns a stream to read the contents from Amazon S3 as
        ///     specified by bucket name and key.
        ///     The caller of this method is responsible for closing the stream.
        /// </summary>
        /// <param name="bucketName">
        ///     The name of the bucket.
        /// </param>
        /// <param name="key">
        ///     The object key.
        /// </param>
        /// <returns>
        ///     A stream containing contents returned from Amazon S3.
        /// </returns>
        public Stream OpenStream(string bucketName, string key)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
                                                       .WithBucketName(bucketName)
                                                       .WithKey(key);

            return(OpenStream(request));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Returns a stream from which the caller can read the content from the specified
        ///     Amazon S3  bucket and key.
        ///     The caller of this method is responsible for closing the stream.
        /// </summary>
        /// <param name="bucketName">
        ///     The name of the bucket.
        /// </param>
        /// <param name="key">
        ///     The object key.
        /// </param>
        /// <returns>
        ///     A stream of the contents from the specified Amazon S3 and key.
        /// </returns>
        public Stream OpenStream(string bucketName, string key)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest
            {
                BucketName = bucketName,
                Key        = key
            };

            return(OpenStream(request));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initiates the asynchronous execution of the OpenStream operation.
        /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.Upload"/>
        /// </summary>
        /// <param name="bucketName">
        ///     The name of the bucket.
        /// </param>
        /// <param name="key">
        ///     The object key.
        /// </param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the AsyncState property.</param>
        /// <exception cref="T:System.ArgumentNullException"></exception>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns>An IAsyncResult that can be used to poll, or wait for results, or both.
        /// This values is also needed when invoking EndOpenStream.</returns>
        public IAsyncResult BeginOpenStream(string bucketName, string key, AsyncCallback callback, object state)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest
            {
                BucketName = bucketName,
                Key        = key
            };

            return(BeginOpenStream(request, callback, state));
        }
        /// <summary>
        ///     Returns a stream from which the caller can read the content from the specified
        ///     Amazon S3  bucket and key.
        ///     The caller of this method is responsible for closing the stream.
        /// </summary>
        /// <param name="bucketName">
        ///     The name of the bucket.
        /// </param>
        /// <param name="key">
        ///     The object key.
        /// </param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task <Stream> OpenStreamAsync(string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken))
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
            {
                BucketName = bucketName,
                Key        = key
            };

            return(OpenStreamAsync(request, cancellationToken));
        }
Ejemplo n.º 8
0
        private Stream OpenStreamHelper(string bucketName, string key)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
            {
                BucketName = bucketName,
                Key        = key
            };

            return(OpenStreamHelper(request));
        }
Ejemplo n.º 9
0
 /// <summary>
 ///     Returns a stream to read the contents from Amazon S3 as
 ///     specified by the <c>TransferUtilityOpenStreamRequest</c>.
 ///     The caller of this method is responsible for closing the stream.
 /// </summary>
 /// <param name="request">
 ///     Contains all the parameters required to open a stream to an S3 object.
 /// </param>
 /// <returns>
 ///     A stream of the contents from Amazon S3.
 /// </returns>
 public Stream OpenStream(TransferUtilityOpenStreamRequest request)
 {
     try
     {
         return(OpenStreamAsync(request).Result);
     }
     catch (AggregateException e)
     {
         ExceptionDispatchInfo.Capture(e.InnerException).Throw();
         return(null);
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 	Returns a stream to read the contents from Amazon S3 as 
        /// 	specified by bucket name and key.
        /// 	The caller of this method is responsible for closing the stream.
        /// </summary>
        /// <param name="bucketName">
        /// 	The name of the bucket.
        /// </param>
        /// <param name="key">
        /// 	The object key.
        /// </param>
        /// <returns>
        /// 	A stream containing contents returned from Amazon S3.
        /// </returns>
        public Stream OpenStream(string bucketName, string key)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
                .WithBucketName(bucketName)
                .WithKey(key);

            return OpenStream(request);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Initiates the asynchronous execution of the OpenStream operation. 
 /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.Upload"/>
 /// </summary>
 /// <param name="request">
 /// 	Contains all the parameters used for opening a stream to an S3 object.
 /// </param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the AsyncState property.</param>
 /// <exception cref="T:System.ArgumentNullException"></exception>
 /// <exception cref="T:System.Net.WebException"></exception>
 /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; 
 /// this value is also needed when invoking EndOpenStream.</returns>
 public IAsyncResult BeginOpenStream(TransferUtilityOpenStreamRequest request, AsyncCallback callback, object state)
 {
     OpenStreamCommand command = new OpenStreamCommand(this._s3Client, request);
     return beginOperation(command, callback, state);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Initiates the asynchronous execution of the OpenStream operation. 
        /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.Upload"/>
        /// </summary>
        /// <param name="bucketName">
        /// 	The name of the bucket.
        /// </param>
        /// <param name="key">
        /// 	The object key.
        /// </param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the AsyncState property.</param>
        /// <exception cref="T:System.ArgumentNullException"></exception>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; 
        /// this value is also needed when invoking EndOpenStream.</returns>
        public IAsyncResult BeginOpenStream(string bucketName, string key, AsyncCallback callback, object state)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
                .WithBucketName(bucketName)
                .WithKey(key);

            return BeginOpenStream(request, callback, state);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 	Returns a stream to read the contents from Amazon S3 as 
 /// 	specified by the <c>TransferUtilityOpenStreamRequest</c>.
 /// 	The caller of this method is responsible for closing the stream.
 /// </summary>
 /// <param name="request">
 /// 	Contains all the parameters required to open a stream to an S3 object.
 /// </param>
 /// <returns>
 /// 	A stream of the contents from Amazon S3.
 /// </returns>
 public Stream OpenStream(TransferUtilityOpenStreamRequest request)
 {
     return OpenStreamHelper(request);
 }
 /// <summary>
 /// 	Returns a stream to read the contents from Amazon S3 as 
 /// 	specified by the <c>TransferUtilityOpenStreamRequest</c>.
 /// 	The caller of this method is responsible for closing the stream.
 /// </summary>
 /// <param name="request">
 /// 	Contains all the parameters required to open a stream to an S3 object.
 /// </param>
 /// <returns>
 /// 	A stream of the contents from Amazon S3.
 /// </returns>
 public Stream OpenStream(TransferUtilityOpenStreamRequest request)
 {
     try
     {
         return OpenStreamAsync(request).Result;
     }
     catch (AggregateException e)
     {
         ExceptionDispatchInfo.Capture(e.InnerException).Throw();
         return null;
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 ///     Returns a stream to read the contents from Amazon S3 as
 ///     specified by the <c>TransferUtilityOpenStreamRequest</c>.
 ///     The caller of this method is responsible for closing the stream.
 /// </summary>
 /// <param name="request">
 ///     Contains all the parameters required to open a stream to an S3 object.
 /// </param>
 /// <returns>
 ///     A stream of the contents from Amazon S3.
 /// </returns>
 public Stream OpenStream(TransferUtilityOpenStreamRequest request)
 {
     return(OpenStreamHelper(request));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 	Returns a stream from which the caller can read the content from the specified
 /// 	Amazon S3  bucket and key.
 /// 	The caller of this method is responsible for closing the stream.
 /// </summary>
 /// <param name="bucketName">
 /// 	The name of the bucket.
 /// </param>
 /// <param name="key">
 /// 	The object key.
 /// </param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// <returns>The task object representing the asynchronous operation.</returns>
 public Task<Stream> OpenStreamAsync(string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken))
 {
     TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
     {
         BucketName = bucketName,
         Key = key
     };
     return OpenStreamAsync(request, cancellationToken);
 }
 /// <summary>
 /// Gets the download stream for a specific content..
 /// </summary>
 /// <param name="content">Descriptor of the item on the remote blob storage.</param>
 /// <returns>The binary stream of the content item.</returns>
 public override Stream GetDownloadStream(IBlobContent content)
 {
     TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
     {
         BucketName = this.bucketName,
         Key = content.FilePath
     };
     var stream = this.transferUtility.OpenStream(request);
     return stream;
 }
Ejemplo n.º 18
0
            private TransferUtilityOpenStreamRequest CreateOpenRequest(DownloadSettings settings)
            {
                TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest();

                request.BucketName = settings.BucketName;

                request.ServerSideEncryptionCustomerProvidedKey = settings.EncryptionKey;
                request.ServerSideEncryptionCustomerProvidedKeyMD5 = settings.EncryptionKeyMD5;
                request.ServerSideEncryptionCustomerMethod = settings.EncryptionMethod;

                if (!String.IsNullOrEmpty(settings.EncryptionKey))
                {
                    request.ServerSideEncryptionCustomerMethod = ServerSideEncryptionCustomerMethod.AES256;
                }

                request.ModifiedSinceDate = settings.ModifiedDate;

                return request;
            }
Ejemplo n.º 19
0
        /// <summary>
        /// Initiates the asynchronous execution of the OpenStream operation.
        /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.Upload"/>
        /// </summary>
        /// <param name="request">
        ///     Contains all the parameters required to open a stream to an Amazon S3 object.
        /// </param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the AsyncState property.</param>
        /// <exception cref="T:System.ArgumentNullException"></exception>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns>An IAsyncResult that can be used to poll, or wait for results, or both.
        /// This values is also needed when invoking EndOpenStream.</returns>
        public IAsyncResult BeginOpenStream(TransferUtilityOpenStreamRequest request, AsyncCallback callback, object state)
        {
            OpenStreamCommand command = new OpenStreamCommand(this._s3Client, request);

            return(beginOperation(command, callback, state));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 	Returns a stream to read the contents from Amazon S3 as 
        /// 	specified by the <c>TransferUtilityOpenStreamRequest</c>.
        /// 	The caller of this method is responsible for closing the stream.
        /// </summary>
        /// <param name="request">
        /// 	Contains all the parameters used for opening a stream to an S3 object.
        /// </param>
        /// <returns>
        /// 	A stream containing contents returned from Amazon S3.
        /// </returns>
        public Stream OpenStream(TransferUtilityOpenStreamRequest request)
        {
            if (!request.IsSetBucketName())
            {
                throw new ArgumentNullException("bucketName", "The bucketName Specified is null or empty!");
            }
            if (!request.IsSetKey())
            {
                throw new ArgumentNullException("key", "The key Specified is null or empty!");
            }

            GetObjectRequest getRequest = convertToGetObjectRequest(request);
            GetObjectResponse response = this._s3Client.GetObject(getRequest);
            return response.ResponseStream;
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 	Returns a stream to read the contents from Amazon S3 as 
 /// 	specified by the <c>TransferUtilityOpenStreamRequest</c>.
 /// 	The caller of this method is responsible for closing the stream.
 /// </summary>
 /// <param name="request">
 /// 	Contains all the parameters required for the OpenStream operation.
 /// </param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// <returns>The task object representing the asynchronous operation.</returns>
 public async Task<Stream> OpenStreamAsync(TransferUtilityOpenStreamRequest request, CancellationToken cancellationToken = default(CancellationToken))
 {
     OpenStreamCommand command = new OpenStreamCommand(this._s3Client, request);
     await command.ExecuteAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
     return command.ResponseStream;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 	Returns a stream to read the contents from Amazon S3 as 
 /// 	specified by the <c>TransferUtilityOpenStreamRequest</c>.
 /// 	The caller of this method is responsible for closing the stream.
 /// </summary>
 /// <param name="request">
 /// 	Contains all the parameters used for opening a stream to an S3 object.
 /// </param>
 /// <returns>
 /// 	A stream containing contents returned from Amazon S3.
 /// </returns>
 public Stream OpenStream(TransferUtilityOpenStreamRequest request)
 {
     OpenStreamCommand command = new OpenStreamCommand(this._s3Client, request);
     command.Execute();
     return command.ResponseStream;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Initiates the asynchronous execution of the OpenStream operation. 
        /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.Upload"/>
        /// </summary>
        /// <param name="bucketName">
        /// 	The name of the bucket.
        /// </param>
        /// <param name="key">
        /// 	The object key.
        /// </param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the AsyncState property.</param>
        /// <exception cref="T:System.ArgumentNullException"></exception>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns>An IAsyncResult that can be used to poll, or wait for results, or both. 
        /// This values is also needed when invoking EndOpenStream.</returns>
        public IAsyncResult BeginOpenStream(string bucketName, string key, AsyncCallback callback, object state)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
            {
                BucketName = bucketName,
                Key = key
            };

            return BeginOpenStream(request, callback, state);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 	Returns a stream from which the caller can read the content from the specified
        /// 	Amazon S3  bucket and key.
        /// 	The caller of this method is responsible for closing the stream.
        /// </summary>
        /// <param name="bucketName">
        /// 	The name of the bucket.
        /// </param>
        /// <param name="key">
        /// 	The object key.
        /// </param>
        /// <returns>
        /// 	A stream of the contents from the specified Amazon S3 and key.
        /// </returns>
        public Stream OpenStream(string bucketName, string key)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest
            {
                BucketName = bucketName,
                Key = key
            };

            return OpenStream(request);
        }
Ejemplo n.º 25
0
        private Stream OpenStreamHelper(string bucketName, string key)
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
            {
                BucketName = bucketName,
                Key = key
            };

            return OpenStreamHelper(request);
        }