fortifyapi/fortify.py
def download_artifact(self, artifact_id):
        """
        You might use this method like this, for example
            api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
            response, file_name = api.download_artifact_scan("my-id")
            if response.success:
                file_content = response.data
                with open('/path/to/some/folder/' + file_name, 'wb') as f:
                    f.write(file_content)
            else:
                print response.message

        We've coded this for the entire file to load into memory. A future change may be to permit
        streaming/chunking of the file and handing back a stream instead of content.
        :param artifact_id: the id of the artifact to download
        :return: binary file data and file name
        """
        file_token = self.get_file_token('DOWNLOAD').data['data']['token']

        url = "/download/artifactDownload.html?mat=" + file_token + "&id=" + str(
            artifact_id) + "&clientVersion=" + self.client_version

        headers = {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate, br',
            'Connection': 'keep-alive'
        }

        response = self._request('GET', url, stream=True, headers=headers)

        try:
            file_name = response.headers['Content-Disposition'].split('=')[1].strip("\"'")
        except:
            file_name = ''

        return response, file_name

        You might use this method like this, for example
            api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
            response, file_name = api.download_artifact_scan("my-id")
            if response.success:
                file_content = response.data
                with open('/path/to/some/folder/' + file_name, 'wb') as f:
                    f.write(file_content)
            else:
                print response.message

        We've coded this for the entire file to load into memory. A future change may be to permit
        streaming/chunking of the file and handing back a stream instead of content.
        :param artifact_id: the id of the artifact to download
        :return: binary file data and file name
        


We've coded this for the entire file to load into memory. A future change may be to permit
streaming/chunking of the file and handing back a stream instead of content.
We ' ve coded this for the entire file to load into memory . A future change may be to permit streaming / chunking of the file and handing back a stream instead of content .
def download_artifact(self, artifact_id):
        file_token = self.get_file_token('DOWNLOAD').data['data']['token']
        url = "/download/artifactDownload.html?mat=" + file_token + "&id=" + str(
            artifact_id) + "&clientVersion=" + self.client_version
        headers = {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate, br',
            'Connection': 'keep-alive'
        }
        response = self._request('GET', url, stream=True, headers=headers)
        try:
            file_name = response.headers['Content-Disposition'].split('=')[1].strip("\"'")
        except:
            file_name = ''
        return response, file_name
def download_artifact ( self , artifact_id ) : file_token = self . get_file_token ( 'DOWNLOAD' ) . data [ 'data' ] [ 'token' ] url = "/download/artifactDownload.html?mat=" + file_token + "&id=" + str ( artifact_id ) + "&clientVersion=" + self . client_version headers = { 'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' , 'Accept-Encoding' : 'gzip, deflate, br' , 'Connection' : 'keep-alive' } response = self . _request ( 'GET' , url , stream = True , headers = headers ) try : file_name = response . headers [ 'Content-Disposition' ] . split ( '=' ) [ 1 ] . strip ( "\"'" ) except : file_name = '' return response , file_name
You might use this method like this, for example
api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
response, file_name = api.download_artifact_scan("my-id")
if response.success:
file_content = response.data
with open('/path/to/some/folder/' + file_name, 'wb') as f:
f.write(file_content)
else:
print response.message
You might use this method like this for example api = FortifyApi ( " https : // my - fortify - server : my - port " token = get_token () ) response file_name = api . download_artifact_scan ( " my - id " ) if response . success : file_content = response . data with open ( ' / path / to / some / folder / ' + file_name ' wb ' ) as f : f . write ( file_content ) else : print response . message
"""
        You might use this method like this, for example
            api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
            response, file_name = api.download_artifact_scan("my-id")
            if response.success:
                file_content = response.data
                with open('/path/to/some/folder/' + file_name, 'wb') as f:
                    f.write(file_content)
            else:
                print response.message

        We've coded this for the entire file to load into memory. A future change may be to permit
        streaming/chunking of the file and handing back a stream instead of content.
        :param artifact_id: the id of the artifact to download
        :return: binary file data and file name
        """
binary file data and file name
binary file data and file name
self
artifact_id
the id of the artifact to download
the id of the artifact to download