(self)
| 576 | return "上传文件文件:{}失败,错误信息为:{}".format(filename, str(e)) |
| 577 | |
| 578 | def upload_proxy(self): |
| 579 | try: |
| 580 | from BTPanel import request |
| 581 | f_name = request.form.get('f_name') |
| 582 | f_path = request.form.get('f_path') |
| 583 | f_size = request.form.get('f_size') |
| 584 | f_start = request.form.get('f_start') |
| 585 | blob_file: FileStorage = request.files.getlist('blob')[0] |
| 586 | url = "{}/files".format(self.origin) |
| 587 | bt_p = self.get_bt_params({"action": "upload"}) |
| 588 | header = {"User-Agent": "Bt-Panel/Node Manager"} |
| 589 | files = {'blob': ('blob', blob_file.stream, 'application/octet-stream')} |
| 590 | data = { |
| 591 | 'f_path': f_path, |
| 592 | 'f_name': f_name, |
| 593 | 'f_size': f_size, |
| 594 | 'f_start': f_start |
| 595 | } |
| 596 | data.update(bt_p) |
| 597 | resp = requests.post(url, data=data, files=files, headers=header, verify=False, timeout=self.timeout) |
| 598 | if not resp.status_code == 200: |
| 599 | return "上传文件响应状态码错误,请检查节点地址和api是否正确,目前状态码为{},返回信息为:{}".format( |
| 600 | resp.status_code, resp.text) |
| 601 | resp_text = resp.text |
| 602 | resp_json = {} |
| 603 | if self.app_key: |
| 604 | resp_text = public.aes_decrypt(resp_text, self.app_key.app_key).strip() |
| 605 | if not resp_text.isdecimal(): |
| 606 | resp_json = json.loads(resp_text) |
| 607 | else: |
| 608 | resp_json = resp.json() |
| 609 | if resp_text.isdecimal(): |
| 610 | return int(resp_text) |
| 611 | elif "status" in resp_json: |
| 612 | return resp_json |
| 613 | else: |
| 614 | return {"status": False, "msg": "上传文件失败,响应信息为:{}".format(resp_text)} |
| 615 | except Exception as e: |
| 616 | public.print_error() |
| 617 | return {"status": False, "msg": "上传文件失败,错误信息为:{}".format(str(e))} |
| 618 | |
| 619 | def remove_file(self, filename: str, is_dir: bool) -> dict: |
| 620 | action = "DeleteDir" if is_dir else "DeleteFile" |
nothing calls this directly
no test coverage detected