Esempio n. 1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetDocumentVersionResponse response = new GetDocumentVersionResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("CustomMetadata", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.CustomMetadata = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Metadata", targetDepth))
                {
                    var unmarshaller = DocumentVersionMetadataUnmarshaller.Instance;
                    response.Metadata = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Esempio n. 2
0
        private async Task <Stream> GetDocumentVersionStreamAsync(String documentId, String versionId)
        {
            GetDocumentVersionRequest getDocumentVersionRequest = new GetDocumentVersionRequest()
            {
                DocumentId          = documentId,
                VersionId           = versionId,
                Fields              = "SOURCE",
                AuthenticationToken = authenticationToken
            };

            GetDocumentVersionResponse response = await client.GetDocumentVersionAsync(getDocumentVersionRequest).ConfigureAwait(false);

            String downloadUrl = response.Metadata.Source[DocumentSourceType.ORIGINAL.Value];

            return(await httpClient.GetStreamAsync(downloadUrl).ConfigureAwait(false));
        }