/// <summary>
        /// Downloads the object at the specified path.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the GetObject service method.</param>
        ///
        /// <returns>The response from the GetObject service method, as returned by MediaStoreData.</returns>
        /// <exception cref="Amazon.MediaStoreData.Model.ContainerNotFoundException">
        /// The specified container was not found for the specified account.
        /// </exception>
        /// <exception cref="Amazon.MediaStoreData.Model.InternalServerErrorException">
        /// The service is temporarily unavailable.
        /// </exception>
        /// <exception cref="Amazon.MediaStoreData.Model.ObjectNotFoundException">
        /// Could not perform an operation on an object that does not exist.
        /// </exception>
        /// <exception cref="Amazon.MediaStoreData.Model.RequestedRangeNotSatisfiableException">
        /// The requested content range is not valid.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mediastore-data-2017-09-01/GetObject">REST API Reference for GetObject Operation</seealso>
        public virtual GetObjectResponse GetObject(GetObjectRequest request)
        {
            var marshaller   = new GetObjectRequestMarshaller();
            var unmarshaller = GetObjectResponseUnmarshaller.Instance;

            return(Invoke <GetObjectRequest, GetObjectResponse>(request, marshaller, unmarshaller));
        }
Ejemplo n.º 2
0
        public void GetObject_RequestedRangeNotSatisfiableExceptionMarshallTest()
        {
            var operation = service_model.FindOperation("GetObject");

            var request         = InstantiateClassGenerator.Execute <GetObjectRequest>();
            var marshaller      = new GetObjectRequestMarshaller();
            var internalRequest = marshaller.Marshall(request);

            TestTools.RequestValidator.Validate("GetObject", request, internalRequest, service_model);

            var exception   = operation.Exceptions.First(e => e.Name.Equals("RequestedRangeNotSatisfiableException"));
            var webResponse = new WebResponseData
            {
                Headers =
                {
                    { "Cache-Control",    "Cache-Control_Value"                                },
                    { "Content-Length",   long.MaxValue.ToString(CultureInfo.InvariantCulture) },
                    { "Content-Range",    "Content-Range_Value"                                },
                    { "Content-Type",     "Content-Type_Value"                                 },
                    { "ETag",             "ETag_Value"                                         },
                    { "Last-Modified",    ValidatorUtils.GetTestDate(TimestampFormat.RFC822)   },
                    { "x-amzn-RequestId", Guid.NewGuid().ToString()                            },
                    { "x-amz-crc32",      "0"                                                  },
                    { "x-amzn-ErrorType", "RequestedRangeNotSatisfiableException"              },
                }
            };

            var payloadResponse = new JsonSampleGenerator(service_model, exception).Execute();

            webResponse.Headers["Content-Length"] = UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString();
            var context  = new JsonUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), true, webResponse, true);
            var response = GetObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK);

            InstantiateClassGenerator.ValidateObjectFullyInstantiated(response);
        }
        public void GetObjectMarshallTest()
        {
            var operation = service_model.FindOperation("GetObject");

            var request    = InstantiateClassGenerator.Execute <GetObjectRequest>();
            var marshaller = new GetObjectRequestMarshaller();

            var internalRequest = marshaller.Marshall(request);

            TestTools.RequestValidator.Validate("GetObject", request, internalRequest, service_model);

            var webResponse = new WebResponseData
            {
                Headers =
                {
                    { "Cache-Control",    "Cache-Control_Value"                                },
                    { "Content-Length",   long.MaxValue.ToString(CultureInfo.InvariantCulture) },
                    { "Content-Range",    "Content-Range_Value"                                },
                    { "Content-Type",     "Content-Type_Value"                                 },
                    { "ETag",             "ETag_Value"                                         },
                    { "Last-Modified",    ValidatorUtils.GetTestDate(TimestampFormat.RFC822)   },
                    { "x-amzn-RequestId", Guid.NewGuid().ToString()                            },
                    { "x-amz-crc32",      "0"                                                  }
                }
            };

            var payloadResponse = new JsonSampleGenerator(service_model, operation.ResponseStructure).Execute();

            webResponse.Headers["Content-Length"] = UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString();
            var context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), false, webResponse);
            ResponseUnmarshaller unmarshaller = GetObjectResponseUnmarshaller.Instance;
            var response = unmarshaller.Unmarshall(context) as GetObjectResponse;

            InstantiateClassGenerator.ValidateObjectFullyInstantiated(response);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the GetObject operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetObject operation on AmazonMediaStoreDataClient.</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>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetObject
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mediastore-data-2017-09-01/GetObject">REST API Reference for GetObject Operation</seealso>
        public virtual IAsyncResult BeginGetObject(GetObjectRequest request, AsyncCallback callback, object state)
        {
            var marshaller   = new GetObjectRequestMarshaller();
            var unmarshaller = GetObjectResponseUnmarshaller.Instance;

            return(BeginInvoke <GetObjectRequest>(request, marshaller, unmarshaller,
                                                  callback, state));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the GetObject operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetObject 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>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mediastore-data-2017-09-01/GetObject">REST API Reference for GetObject Operation</seealso>
        public virtual Task <GetObjectResponse> GetObjectAsync(GetObjectRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new GetObjectRequestMarshaller();
            var unmarshaller = GetObjectResponseUnmarshaller.Instance;

            return(InvokeAsync <GetObjectRequest, GetObjectResponse>(request, marshaller,
                                                                     unmarshaller, cancellationToken));
        }
Ejemplo n.º 6
0
        public void GreedyPathStartingWithoutSlashTest()
        {
            var request = InstantiateClassGenerator.Execute <GetObjectRequest>();

            request.Path = "TestPath/foo/bar";
            var marshaller = new GetObjectRequestMarshaller();

            var internalRequest = marshaller.Marshall(request);

            Assert.AreEqual(internalRequest.ResourcePath, "/" + request.Path);
        }
        /// <summary>
        /// Get S3 Object
        /// This fucntion can only be called in main thread
        /// </summary>
        /// <param name="GetObjectRequest"> Get Object request </param>
        /// <param name="callback"> Call back function is fired after async operation is completed </param>
        public void GetObjectAsync(GetObjectRequest request, AmazonServiceCallback callback, object state)
        {
            if (!AmazonInitializer.IsInitialized)
            {
                throw new Exception("AWSPrefab is not added to the scene");
            }

            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
            {
                var marshaller   = new GetObjectRequestMarshaller();
                var unmarshaller = GetObjectResponseUnmarshaller.GetInstance();
                Invoke(request, callback, state, marshaller, unmarshaller, signer);
            }));
            return;
        }
        public void ExpectedBucketOwnerSetTest()
        {
            string ExpectedBucketOwnerHeader = "x-amz-expected-bucket-owner";
            string ExpectedBucketOwnerValue  = "testaccount";

            var requestObject = new GetObjectRequest
            {
                Key                 = "testKey",
                BucketName          = "testBucket",
                ExpectedBucketOwner = ExpectedBucketOwnerValue
            };

            GetObjectRequestMarshaller marshaller = new GetObjectRequestMarshaller();
            var request = marshaller.Marshall(requestObject);

            Assert.IsTrue(request.Headers.ContainsKey(ExpectedBucketOwnerHeader));
            Assert.AreEqual(request.Headers[ExpectedBucketOwnerHeader], ExpectedBucketOwnerValue);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetObject operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetObject 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 Task<GetObjectResponse> GetObjectAsync(GetObjectRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetObjectRequestMarshaller();
            var unmarshaller = GetObjectResponseUnmarshaller.Instance;

            return InvokeAsync<GetObjectRequest,GetObjectResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Ejemplo n.º 10
0
        internal GetObjectResponse GetObject(GetObjectRequest request)
        {
            var marshaller = new GetObjectRequestMarshaller();
            var unmarshaller = GetObjectResponseUnmarshaller.Instance;

            return Invoke<GetObjectRequest,GetObjectResponse>(request, marshaller, unmarshaller);
        }
Ejemplo n.º 11
0
 IAsyncResult invokeGetObject(GetObjectRequest getObjectRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new GetObjectRequestMarshaller().Marshall(getObjectRequest);
     var unmarshaller = GetObjectResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetObject operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the GetObject operation on AmazonS3Client.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">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>
 public void GetObjectAsync(GetObjectRequest request, AmazonServiceCallback<GetObjectRequest, GetObjectResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new GetObjectRequestMarshaller();
     var unmarshaller = GetObjectResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<GetObjectRequest,GetObjectResponse> responseObject 
                     = new AmazonServiceResult<GetObjectRequest,GetObjectResponse>((GetObjectRequest)req, (GetObjectResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<GetObjectRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetObject operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetObject operation on AmazonS3Client.</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>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetObject
        ///         operation.</returns>
        public IAsyncResult BeginGetObject(GetObjectRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new GetObjectRequestMarshaller();
            var unmarshaller = GetObjectResponseUnmarshaller.Instance;

            return BeginInvoke<GetObjectRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetObject operation.
        /// <seealso cref="Amazon.S3.IAmazonS3.GetObject"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetObject 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 Task<GetObjectResponse> GetObjectAsync(GetObjectRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetObjectRequestMarshaller();
            var unmarshaller = GetObjectResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, GetObjectRequest, GetObjectResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// <para>Retrieves objects from Amazon S3.</para>
        /// </summary>
        /// 
        /// <param name="getObjectRequest">Container for the necessary parameters to execute the GetObject service method on AmazonS3.</param>
        /// 
        /// <returns>The response from the GetObject service method, as returned by AmazonS3.</returns>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public async Task<GetObjectResponse> GetObjectAsync(GetObjectRequest getObjectRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetObjectRequestMarshaller();
            var unmarshaller = GetObjectResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, GetObjectRequest, GetObjectResponse>(getObjectRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }