Ejemplo n.º 1
0
        public void SaveImage(DiscogsImage dImage, string path, string fileName, DiscogsImageFormatType type = DiscogsImageFormatType.Normal)
        {
            var uri     = (type == DiscogsImageFormatType.Normal) ? dImage.uri : dImage.uri150;
            var request = new RestRequest(uri, Method.GET);
            var bytes   = client.DownloadData(request);

            File.WriteAllBytes(Path.Combine(path, fileName), bytes);
        }
Ejemplo n.º 2
0
        public async Task <string> SaveImageAsync(DiscogsImage image, string path, string fileName, CancellationToken cancellationToken, DiscogsImageFormatType type = DiscogsImageFormatType.Normal)
        {
            var url = (type == DiscogsImageFormatType.Normal) ? image.uri : image.uri150;

            return(await _Client.SaveFile(url, path, fileName, cancellationToken));
        }
Ejemplo n.º 3
0
 public Task <string> SaveImageAsync(DiscogsImage image, string path, string fileName, DiscogsImageFormatType type = DiscogsImageFormatType.Normal)
 {
     return(SaveImageAsync(image, path, fileName, CancellationToken.None, type));
 }
Ejemplo n.º 4
0
 public async Task DownloadImageAsync(DiscogsImage image, Stream copyStream, CancellationToken cancellationToken, DiscogsImageFormatType type = DiscogsImageFormatType.Normal)
 {
     var url = (type == DiscogsImageFormatType.Normal) ? image.uri : image.uri150;
     await _Client.Download(url, copyStream, cancellationToken);
 }
Ejemplo n.º 5
0
 public Task DownloadImageAsync(DiscogsImage image, Stream copyStream, DiscogsImageFormatType type = DiscogsImageFormatType.Normal)
 {
     return(DownloadImageAsync(image, copyStream, CancellationToken.None, type));
 }
Ejemplo n.º 6
0
        public async Task SaveImage(DiscogsImage image, string path, string fileName, CancellationToken cancellationToken, DiscogsImageFormatType type = DiscogsImageFormatType.Normal)
        {
            var url       = (type == DiscogsImageFormatType.Normal) ? image.uri : image.uri150;
            var extension = Path.GetExtension(url);
            var fullPath  = Path.Combine(path, fileName + extension);

            using (var writer = File.Create(fullPath))
            {
                await DownloadImage(image, writer, cancellationToken, type);
            }
        }