OneDrive/ODConnection.public.cs
/// <summary>
/// Generates a service request to download the binary contents of a file based on an item ID.
/// </summary>
/// <param name="itemReference"></param>
/// <param name = "options"></param>
/// <returns></returns>
Generates a service request to download the binary contents of a file based on an item ID.
Generates a service request to download the binary contents of a file based on an item ID .
public async Task<Stream> DownloadStreamForItemAsync(ODItemReference itemReference, StreamDownloadOptions options)
        {
            if (!itemReference.IsValid())
                throw new ArgumentException("ItemReference was invalid. Requires either an ID or Path");
            Uri serviceUri = UriForItemReference(itemReference, ApiConstants.ContentRelationshipName);
            var request = await CreateHttpRequestAsync(serviceUri, ApiConstants.HttpGet);
            options.ModifyRequest(request);
            var response = await GetHttpResponseAsync(request);
            if (response.StatusCode == System.Net.HttpStatusCode.Found)
            {
                Uri downloadUri = new Uri(response.Headers[ApiConstants.LocationHeaderName]);
                request = await CreateHttpRequestAsync(downloadUri, ApiConstants.HttpGet);
                options.ModifyRequest(request);
                response = await GetHttpResponseAsync(request);
            }
            var responseStream = await response.GetResponseStreamAsync();
            return responseStream;
        }
public async Task < Stream > DownloadStreamForItemAsync ( ODItemReference itemReference , StreamDownloadOptions options ) { if ( ! itemReference . IsValid ( ) ) throw new ArgumentException ( " " ) ; Uri serviceUri = UriForItemReference ( itemReference , ApiConstants . ContentRelationshipName ) ; var request = await CreateHttpRequestAsync ( serviceUri , ApiConstants . HttpGet ) ; options . ModifyRequest ( request ) ; var response = await GetHttpResponseAsync ( request ) ; if ( response . StatusCode == System . Net . HttpStatusCode . Found ) { Uri downloadUri = new Uri ( response . Headers [ ApiConstants . LocationHeaderName ] ) ; request = await CreateHttpRequestAsync ( downloadUri , ApiConstants . HttpGet ) ; options . ModifyRequest ( request ) ; response = await GetHttpResponseAsync ( request ) ; } var responseStream = await response . GetResponseStreamAsync ( ) ; return responseStream ; }
Generates a service request to download the binary contents of a file based on an item ID.
Generates a service request to download the binary contents of a file based on an item ID .
None
itemReference
ODItemReference
None
options
StreamDownloadOptions
None