get image as stream method

This commit is contained in:
2015-03-27 00:29:36 +01:00
parent 063ad18f2c
commit 8494b9c9ff
5 changed files with 27 additions and 5 deletions
+11
View File
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
@@ -43,6 +44,16 @@ namespace OnePeek.Api
}
/// <summary>
/// HTTP GET request (as stream) to the specified uri
/// </summary>
public async Task<Stream> GetStream(Uri uri)
{
HttpResponseMessage responseMessage = await httpClient.GetAsync(uri);
return await responseMessage.Content.ReadAsStreamAsync();
}
public void Dispose()
{
httpClient.Dispose();
+10
View File
@@ -7,6 +7,8 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bender.Configuration;
using System.IO;
namespace OnePeek.Api
{
@@ -43,5 +45,13 @@ namespace OnePeek.Api
string type = screenshotType.GetEnumDisplayName();
return EndpointUris.GetWindowsPhoneImageUri(urn, type);
}
public async Task<Stream> GetImageAsStream(string urn, StoreScreenshotType screenshotType)
{
string type = screenshotType.GetEnumDisplayName();
Uri uri = EndpointUris.GetWindowsPhoneImageUri(urn, type);
return await ApiHttpClient.Instance.GetStream(uri);
}
}
}
+2 -1
View File
@@ -13,7 +13,7 @@
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
<TargetFrameworkProfile>Profile44</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -45,6 +45,7 @@
<Compile Include="ApiHttpClient.cs" />
<Compile Include="AppMetadataEndpoint.cs" />
<Compile Include="EndpointUris.cs" />
<Compile Include="Extensions\EnumExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
+1 -1
View File
@@ -2,7 +2,7 @@
<packages>
<package id="Bender" version="3.0.4.0" targetFramework="portable-net451+win81+wpa81" />
<package id="flexo" version="1.0.0.18" targetFramework="portable-net451+win81+wpa81" />
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="portable-net451+win81+wpa81" />
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="portable-net451+win81+wpa81" requireReinstallation="True" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="portable-net451+win81+wpa81" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="portable-net451+win81+wpa81" />
</packages>
+3 -3
View File
@@ -42,9 +42,9 @@
<Compile Include="AppRating.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StoreCulture.cs" />
<Compile Include="StoreCultureTypeEnum.cs" />
<Compile Include="StoreScreenshotTypeEnum.cs" />
<Compile Include="StoreTypeEnum.cs" />
<Compile Include="StoreCultureType.cs" />
<Compile Include="StoreScreenshotType.cs" />
<Compile Include="StoreType.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.