Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d6702d2

Browse files
authored
Add files via upload
1 parent 9281cb8 commit d6702d2

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)

AltStyle によって変換されたページ (->オリジナル) /