Commit c49bd43f authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added remove to upload file example.

parent 5baa6b69
Pipeline #67289 passed with stages
in 12 minutes and 44 seconds
......@@ -11,6 +11,7 @@ from urllib.parse import urlparse, urlencode
import requests
import re
import time
import os
import os.path
import tarfile
import io
......@@ -135,8 +136,11 @@ def upload_next_data(sources: Iterator[Tuple[str, str, str]], upload_name='next
with open(zipfile_name, 'wb') as f:
for c in content():
f.write(c)
with open(zipfile_name, 'rb') as f:
response = requests.put(url=url, headers={'X-Token': token, 'Content-type': 'application/octet-stream'}, data=f)
try:
with open(zipfile_name, 'rb') as f:
response = requests.put(url=url, headers={'X-Token': token, 'Content-type': 'application/octet-stream'}, data=f)
finally:
os.remove(zipfile_name)
if response.status_code != 200:
raise Exception('nomad return status %d' % response.status_code)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment