1234567891011121314151617181920212223242526272829303132333435 |
- import base64
- import json
- import os
- import sys
- sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../")
- from format_convert.utils import get_platform, request_post
- def test_one(p, from_remote=False):
- with open(p, "rb") as f:
- file_bytes = f.read()
- file_base64 = base64.b64encode(file_bytes)
- data = {"file": file_base64, "type": p.split(".")[-1], "filemd5": 100}
- if from_remote:
- _url = 'http://172.20.1.251:15010/convert'
- # _url = 'http://192.168.2.102:15010/convert'
- # _url = 'http://172.16.160.65:15010/convert'
- result = json.loads(request_post(_url, data, time_out=10000))
- else:
- print("only support remote!")
- print("result_text", result.get("result_text")[0][:20])
- print("is_success", result.get("is_success"))
- if __name__ == '__main__':
- if get_platform() == "Windows":
- # file_path = "C:/Users/Administrator/Desktop/error7.jpg"
- # file_path = "D:/BIDI_DOC/比地_文档/2022/Test_Interface/20210609202634853485.xlsx"
- # file_path = "D:/BIDI_DOC/比地_文档/2022/Test_ODPS/1624325845476.pdf"
- file_path = "C:/Users/Administrator/Downloads/1650967920520.pdf"
- else:
- file_path = "test1.doc"
- test_one(file_path, from_remote=True)
|