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

How to stop downloading files on error response? #251

Open
KingZee opened this issue Oct 24, 2024 · 1 comment
Open

How to stop downloading files on error response? #251

KingZee opened this issue Oct 24, 2024 · 1 comment

Comments

@KingZee
Copy link

KingZee commented Oct 24, 2024

    public void DownloadFile(string fileName)
    {
        string url = mainLink + "files/" + fileName;
        string localPath = Path.Combine(DataManager.videosFolder + fileName);

        if (!System.IO.File.Exists(localPath))
        {
            RestClient.Get(new RequestHelper
            {
                Uri = url,
                DownloadHandler = new DownloadHandlerFile(Path.Combine(localPath)),
                Timeout = 13,
                Retries = 0,
                IgnoreHttpException = false
            }).Then(response =>
            {
                if (response.Request.downloadHandler.isDone)
                {
                    Popup.main.DisplayMessage(Popup.Style.Blue, "Completed video download!", false);
                }
            }).Catch(ErrorHandler);
        }
    }

On an http exception ErrorHandler is called and code works, but the errored response is downloaded and stored as a file (Cannot GET /files/xx), do I have to delete it every time or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@KingZee and others