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

文件下载地址若失效,会走onDownloadSuccess回调 #22

Open
stars-one opened this issue Aug 10, 2022 · 0 comments
Open

文件下载地址若失效,会走onDownloadSuccess回调 #22

stars-one opened this issue Aug 10, 2022 · 0 comments

Comments

@stars-one
Copy link

测试连接:https://down.wss.show/3dyl80b/9/0d/90do3dyl80b?cdn_sign=1660120096-5-0-bcca8f1d079bc819fefda02d5acb3d9f&exp=240&response-content-disposition=attachment%3B%20filename%3D%22%E6%B5%8B%E8%AF%95111_1.0.1.apk%22%3B%20filename%2A%3Dutf-8%27%27%25E6%25B5%258B%25E8%25AF%2595111_1.0.1.apk

http错误码为403,但是会走onDownloadSuccess()回调,可以修复下

代码如下:

HttpRequest.DOWNLOAD(
                    ActivityUtils.getTopActivity(), downloadUrl,
                    file,
                    new OnDownloadListener() {
                        @Override
                        public void onDownloadSuccess(File file) {
                            progressDialog.dismiss();
                            if (file.length() > 0) {
                                //下载完毕后安装apk文件
                                AppUtils.installApp(file);
                            } else {
                                ToastUtils.showShort("apk文件大小为0KB,更新失败!");
                            }
                        }

                        @Override
                        public void onDownloading(int progress) {
                            KLog.d("下载进度:" + progress);
                            //更新进度
                            progressDialog.setProgress(progress);
                        }

                        @Override
                        public void onDownloadFailed(Exception e) {
                            ToastUtils.showShort("下载失败,原因:" + e.getMessage());
                        }
                    }
            );
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

1 participant