Skip to main content

File Scan | Python SDK

init

FileScan()

download-file

FileScan.download_file()

Scan

FileScan.file_scan(file, file_path, verbose, raw, provider, sync_call)

Scan a file for malicious content.

optional parameters

io.BufferedReader

file to be scanned (should be opened with read permissions and in binary format)

str

filepath to be opened and scanned

bool

Echo the API parameters in the response

bool

Include raw data from this provider

str

Scan file using this provider

bool

True to wait until server returns a result, False to return immediately and retrieve result asynchronously

Response Object

A PangeaResponse where the sanctioned source(s) are in the response.result field. Available response fields can be found in our API Documentation.

try:
    with open("./path/to/file.pdf", "rb") as f:
        response = client.file_scan(file=f, verbose=True, provider="crowdstrike")
        print(f"Response: {response.result}")
except pe.PangeaAPIException as e:
    print(f"Request Error: {e.response.summary}")
    for err in e.errors:
        print(f"\t{err.detail} \n")

Poll result

FileScan.poll_result(exception)

Returns request's result that has been accepted by the server

required parameters

AcceptedRequestException

Exception raise by SDK on the call that is been processed.

Response Object

PangeaResponse

response = service.poll_result(exception)

request-upload-url

FileScan.request_upload_url()