Add test script for uploading to S3
This commit is contained in:
parent
c699d4fda0
commit
0ceda9e53a
BIN
minio_upload/mpv-shot0001.jpg
Normal file
BIN
minio_upload/mpv-shot0001.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 360 KiB |
30
minio_upload/upload.py
Normal file
30
minio_upload/upload.py
Normal file
@ -0,0 +1,30 @@
|
||||
import requests
|
||||
import shutil
|
||||
|
||||
host = 'https://minio.eidelpes.info/aic-g4t2/'
|
||||
remote_filename = 'testing2.jpg'
|
||||
|
||||
url = host + remote_filename
|
||||
|
||||
local_filename = 'mpv-shot0001.jpg'
|
||||
|
||||
headers = {'Content-Type': 'image/jpeg'}
|
||||
|
||||
# PUT image named 'mpv-shot0001.jpg' to 'testing2.jpg'
|
||||
r = requests.put(url, data=open(local_filename, 'rb'), headers=headers)
|
||||
|
||||
if r.status_code == 200:
|
||||
print("Successfully uploaded a file!")
|
||||
else:
|
||||
print("Something went wrong")
|
||||
exit()
|
||||
|
||||
r = requests.get(url, stream=True)
|
||||
if r.status_code == 200:
|
||||
with open('file_downloaded.jpg', 'wb') as f:
|
||||
r.raw.decode_content = True
|
||||
shutil.copyfileobj(r.raw, f)
|
||||
print("Successfully downloaded the file and saved it in 'file_downloaded.jpg'")
|
||||
else:
|
||||
print("Something went wrong while downloading the file!")
|
||||
exit()
|
||||
Loading…
x
Reference in New Issue
Block a user