-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmpfiles.py
More file actions
33 lines (24 loc) · 988 Bytes
/
tmpfiles.py
File metadata and controls
33 lines (24 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import requests
def upload_data():
image_list = os.listdir("outputs/edit_results")
res = {}
for i in range(len(image_list)):
if image_list[i][-3:] == "png":
path = "outputs/edit_results/" + image_list[i]
files = {
'file': open(path, 'rb'),
}
response = requests.post('https://tmpfiles.org/api/v1/upload', files=files)
res['image'] = response.json()['data']['url']
sample_name_list = os.listdir('outputs/edit_results/samples/images')
sample_url_list = []
for i in range(len(sample_name_list)):
path = 'outputs/edit_results/samples/images/' + sample_name_list[i]
files = {
'file': open(path, 'rb'),
}
response = requests.post('https://tmpfiles.org/api/v1/upload', files=files)
sample_url_list.append(response.json()['data']['url'])
res['samples'] = sample_url_list
return res