bezzad / Downloader

Fast, cross-platform and reliable multipart downloader with asynchronous progress events for .NET applications.
MIT License
1.35k stars 204 forks source link

Can not download twitter images #170

Open hupo376787 opened 4 weeks ago

hupo376787 commented 4 weeks ago

No error, no file downloaded

try
{

    var downloader = new DownloadService();
    string file = @"d:/aa.jpg";
    string url = @"https://pbs.twimg.com/media/GbLEYYyWYAAE767.jpg";
    await downloader.DownloadFileTaskAsync(url, file);

}
catch (Exception ex)
{

}
bezzad commented 4 weeks ago

I was able to download the file without any issues. However, I have two suggestions for you:

File Path Format : Please ensure that the file path you provided is correct. In Windows OS, the path should be formatted as "d:\aa.jpg" instead of "d:/aa.jpg".

Error Handling : Please add the following code to your downloader object to catch any errors during the download process:

downloader.DownloadFileCompleted += (sender, args) => {
    if (args.Cancelled)
        Console.WriteLine("Download Canceled.");

    if (args.Error is not null) {
        Console.WriteLine("Error: " + args.Error.Message);

        if (args.Error.InnerException != null) 
            Console.Error.WriteLine("Inner Exception: " + args.Error.InnerException.Message);
    }
};

This will help you diagnose any issues that may arise during the download. If you have any further questions, feel free to ask!

hupo376787 commented 3 weeks ago

Hi, sorry for the late reply. I catch the error using your code.

Error: The SSL connection could not be established, see inner exception.
Inner Exception: The SSL connection could not be established, see inner exception.

It seems my network problem.

hupo376787 commented 3 weeks ago

Hi, I tried another project, https://github.com/rogerfar/Downloader.NET It can download the image.

string url = "https://pbs.twimg.com/media/GbLEYYyWYAAE767.jpg";
string path = "result.jpg";
var downloader0 = new DownloaderNET.Downloader(url, path);
await downloader0.Download();

Now it seems that the inner exception did exit.