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

关于文件上传,设置全局请求拦截 #16

Open
Cjiio opened this issue Apr 27, 2021 · 0 comments
Open

关于文件上传,设置全局请求拦截 #16

Cjiio opened this issue Apr 27, 2021 · 0 comments

Comments

@Cjiio
Copy link

Cjiio commented Apr 27, 2021

设置全局请求拦截后,根据业务需求,需要清除原数据,将原请求数据加密后请求,但是好像同时把文件上传的请求也清除了,导致上传文件后报错文件路径无效,不能够进行正常的文件上传

        BaseOkHttp.parameterInterceptListener = (ParameterInterceptListener<Parameter>) (context, url, parameter) -> {
            String data = parameter.toParameterString();
            parameter.clear();
            parameter.add("sign",SignData(data));
            parameter.add("data", RC4_jm(data));
            return parameter;
        };
                    File archive=new File(path);
                    String SignTime = Long.toString(System.currentTimeMillis());
                    WaitDialog.show((AppCompatActivity) requireActivity(), "请稍候...正在上传中..");
                    HttpRequest.build(requireActivity(), "api.php?app=10000&act=upload")
                            .addHeaders("Charset", "UTF-8")
                            .addParameter("type", "bak")
                            .addParameter("token", token)
                            .addParameter("cdname", name)
                            .addParameter("archive_md5",getFileMD5s(archive,32))
                            .addParameter("bz", inputStr)
                            .addParameter("file",archive)
                            .addParameter("t",SignTime)
                            .setJsonResponseListener(new JsonResponseListener() {
                                @Override
                                public void onResponse(JsonMap main, Exception error) {
                                    WaitDialog.dismiss();
                                    JsonMap msg = new JsonMap(RC4_jm2(main.getString("msg")));
                                    if (error == null) {
                                        if (main.getString("code").equals("200")){
                                            Toasty.success(requireContext(),"存档备份完成",Toasty.LENGTH_SHORT).show();
                                        }else {
                                            Toasty.info(requireContext(),msg.toString(),Toasty.LENGTH_SHORT).show();
                                        }
                                    } else {
                                        Toasty.error(requireContext(),"备份失败:"+error,Toasty.LENGTH_SHORT).show();
                                    }
                                }
                            })
                            .doPost();
                }
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