code: def analysis_download(self, webid, type, run=None, file=None):
          
  
          # when no file is specified, we create our own
          if file is None:
              _file = io.BytesIO()
          else:
              _file = file
  
          data = {
              'apikey': self.apikey,
              'webid': webid,
              'type': type,
              'run': run,
          }
  
          response = self._post(self.apiurl + "/v2/analysis/download", data=data, stream=True)
  
          try:
              filename = response.headers["Content-Disposition"].split("filename=")[1][1:-2]
          except Exception as e:
              filename = type
  
          # do standard error handling when encountering an error (i.e. throw an exception)
          if not response.ok:
              self._raise_or_extract(response)
              raise RuntimeError("Unreachable because statement above should raise.")
  
          try:
              for chunk in response.iter_content(1024):
                  _file.write(chunk)
          except requests.exceptions.RequestException as e:
              raise ConnectionError(e)
  
          # no user file means we return the content
          if file is None:
              return (filename, _file.getvalue())
          else:
              return filename
docs: Download a resource for an analysis. E.g. the full report, binaries, screenshots.
          The full list of resources can be found in our API documentation.
  
          When `file` is given, the return value is the filename specified by the server,
          otherwise it's a tuple of (filename, bytes).
  
          Parameters:
              webid: the webid of the analysis
              type: the report type, e.g. 'html', 'bins'
              run: specify the run. If it is None, let Joe Sandbox pick one
              file: a writeable file-like object (When obmitted, the method returns
                    the data as a bytes object.)
  
          Example:
  
              json_report, name = joe.analysis_download(123456, 'jsonfixed')
  
          Example:
  
              with open("full_report.html", "wb") as f:
                  name = joe.analysis_download(123456, "html", file=f)