Amazon.S3.Transfer.Internal.OpenStreamCommand.Execute C# (CSharp) Method

Execute() public method

public Execute ( ) : void
return void
        public override void Execute()
        {
            if (!this._request.IsSetBucketName())
            {
                throw new InvalidOperationException("The bucketName Specified is null or empty!");
            }
            if (!this._request.IsSetKey())
            {
                throw new InvalidOperationException("The key Specified is null or empty!");
            }

            GetObjectRequest getRequest = ConvertToGetObjectRequest(this._request);
            GetObjectResponse response = this._s3Client.GetObject(getRequest);
            this._responseStream = response.ResponseStream;
        }

Usage Example

 /// <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;
 }