Skip to content

Commit 6e7a317

Browse files
committed
2 parents 1041816 + d6702d2 commit 6e7a317

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

convert.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python3
2+
3+
import requests
4+
import os,json
5+
6+
from requests_toolbelt import MultipartEncoder
7+
8+
url = "http://localhost/unoconv/pdf"
9+
10+
def post_file(url,path):
11+
filename = os.path.basename(path)
12+
convert_name = str(filename).split('.')[0] + '.pdf'
13+
14+
m = MultipartEncoder(
15+
fields= {
16+
'file':(filename,open(path,'rb')),
17+
}
18+
)
19+
response = requests.request('POST', url, data=m, headers={'Content-Type':m.content_type})
20+
21+
with open(convert_name, 'wb') as f:
22+
f.write(response.content)
23+
24+
return convert_name
25+
26+
path = "./demo.docx"
27+
28+
ret = post_file(url, path)
29+
print(ret)
30+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy