ImageService.DownloadImage C# (CSharp) Method

DownloadImage() public static method

public static DownloadImage ( string imageUrl ) : Task
imageUrl string
return Task
    public static Task<byte[]> DownloadImage(string imageUrl)
    {
        if (!imageUrl.Trim().StartsWith("https", StringComparison.OrdinalIgnoreCase))
            throw new Exception("iOS and Android Require Https");
        return _client.GetByteArrayAsync(imageUrl);
    }
}

Usage Example

Beispiel #1
0
        private async void Prueba(string url)
        {
            var downloadedImage = await ImageService.DownloadImage(url);

            Stream stream = new MemoryStream(downloadedImage);

            Myfoto.Source = ImageSource.FromStream(() => new MemoryStream(downloadedImage));

            // DependencyService.Get<IFileService>().SavePicture((Preferences.Get("UserID", 0)).ToString() + ".jpg", stream);
        }
All Usage Examples Of ImageService::DownloadImage
ImageService