Skip to main content

Sanitize | Python SDK

Initializes a new Pangea service client.

Sanitize(token, config, logger_name)

required parameters

str

Pangea API token.

optional parameters

PangeaConfig | None

Configuration.

str

Logger name.

download-file

Sanitize.download_file()

Poll result

Sanitize.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)

Sanitize via presigned URL

Sanitize.request_upload_url(transfer_method, params, file_scan, content, share_output, size, crc32c, sha256, uploaded_file_name)

Apply file sanitization actions according to specified rules via a presigned URL.

optional parameters

TransferMethod

The transfer method used to upload the file data.

Optional[FileUploadParams]

File upload parameters.

Optional[SanitizeFile]

Options for File Scan.

Optional[SanitizeContent]

Options for how the file should be sanitized.

Optional[SanitizeShareOutput]

Integration with Secure Share.

Optional[int]

The size (in bytes) of the file. If the upload doesn't match, the call will fail.

Optional[str]

The CRC32C hash of the file data, which will be verified by the server if provided.

Optional[str]

The hexadecimal-encoded SHA256 hash of the file data, which will be verified by the server if provided.

Optional[str]

Name of the user-uploaded file, required for TransferMethod.PUT_URL and TransferMethod.POST_URL.

Response Object

A presigned URL.

presignedUrl = sanitize.request_upload_url(
    transfer_method=TransferMethod.PUT_URL,
    uploaded_file_name="uploaded_file",
)

# Upload file to `presignedUrl.accepted_result.put_url`.

# Poll for Sanitize's result.
response: PangeaResponse[SanitizeResult] = sanitize.poll_result(response=presignedUrl)

Sanitize

Sanitize.sanitize(transfer_method, file_path, file, source_url, share_id, file_scan, content, share_output, size, crc32c, sha256, uploaded_file_name, sync_call)

Apply file sanitization actions according to specified rules.

optional parameters

TransferMethod

The transfer method used to upload the file data.

Optional[str]

Path to file to sanitize.

Optional[io.BufferedReader]

File to sanitize.

Optional[str]

A URL where the file to be sanitized can be downloaded.

Optional[str]

A Pangea Secure Share ID where the file to be sanitized is stored.

Optional[SanitizeFile]

Options for File Scan.

Optional[SanitizeContent]

Options for how the file should be sanitized.

Optional[SanitizeShareOutput]

Integration with Secure Share.

Optional[int]

The size (in bytes) of the file. If the upload doesn't match, the call will fail.

Optional[str]

The CRC32C hash of the file data, which will be verified by the server if provided.

Optional[str]

The hexadecimal-encoded SHA256 hash of the file data, which will be verified by the server if provided.

Optional[str]

Name of the user-uploaded file, required for TransferMethod.PUT_URL and TransferMethod.POST_URL.

bool

Whether or not to poll on HTTP/202.

Response Object

The sanitized file and information on the sanitization that was performed.

with open("/path/to/file.pdf", "rb") as f:
response = sanitize.sanitize(
    file=f,
    transfer_method=TransferMethod.POST_URL,
    uploaded_file_name="uploaded_file",
)