Skip to main content

File Scan | Python SDK

Initializes a new Pangea service client.

FileScan(token, config, logger_name)

required parameters

str

Pangea API token.

optional parameters

PangeaConfig | None

Configuration.

str

Logger name.

download-file

FileScan.download_file()

Scan

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

Scan a file for malicious content.

optional parameters

str

filepath to be opened and scanned

io.BufferedReader

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

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

TransferMethod

Transfer method used to upload the file data.

str

A URL where the Pangea APIs can fetch the contents of the input file.

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

optional parameters

Optional[AcceptedRequestException]

Exception that was previously raised by the SDK on a call that is being processed.

Response Object

PangeaResponse

response = service.poll_result(exception)

request-upload-url

FileScan.request_upload_url()