Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not download twitter images #170

Open
hupo376787 opened this issue Oct 31, 2024 · 3 comments
Open

Can not download twitter images #170

hupo376787 opened this issue Oct 31, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@hupo376787
Copy link

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
Copy link
Owner

bezzad commented Oct 31, 2024

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!

@bezzad bezzad added the question Further information is requested label Oct 31, 2024
@bezzad bezzad self-assigned this Oct 31, 2024
@hupo376787
Copy link
Author

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
Status: No status
Development

No branches or pull requests

2 participants