orthancFileBrowser.py 737 B

1234567891011121314151617181920212223242526
  1. import urllib3
  2. import shutil
  3. class orthancFileBrowser:
  4. def __init__(self,net):
  5. self.net=net
  6. def getZip(self,retrieveLevel, dataId, path):
  7. url=self.net.getCoreURL()
  8. url+="/"+retrieveLevel+"/"+dataId+"/archive";
  9. print("Using: {}".format(url))
  10. response=self.net.get(url,binary=True);
  11. with open(path,'wb') as out_file:
  12. shutil.copyfileobj(response,out_file)
  13. response.release_conn()
  14. #response.data is a byte array -> is the same as file
  15. def upload(self,path):
  16. url=self.net.getCoreURL()
  17. url+="/instances"
  18. with open(path,'rb') as f:
  19. response=self.net.post(url,"octet-stream", f.read())
  20. print(response.data)