1234567891011121314151617181920212223242526 |
- import urllib3
- import shutil
- class orthancFileBrowser:
- def __init__(self,net):
- self.net=net
- def getZip(self,retrieveLevel, dataId, path):
- url=self.net.getCoreURL()
- url+="/"+retrieveLevel+"/"+dataId+"/archive";
- print("Using: {}".format(url))
- response=self.net.get(url,binary=True);
- with open(path,'wb') as out_file:
- shutil.copyfileobj(response,out_file)
- response.release_conn()
- #response.data is a byte array -> is the same as file
- def upload(self,path):
- url=self.net.getCoreURL()
- url+="/instances"
- with open(path,'rb') as f:
- response=self.net.post(url,"octet-stream", f.read())
- print(response.data)
|