Sanitize | Node.js SDK
Sanitize
constructor(token: string, config: PangeaConfig): SanitizeServiceCreates a new SanitizeService
with the given Pangea API token and
configuration.
const config = new PangeaConfig({ domain: "pangea_domain" });
const sanitize = new SanitizeService("pangea_token", config);
Sanitize via presigned URL
requestUploadURL(request: SanitizeRequest): Promise<PangeaResponse<SanitizeResult>>Apply file sanitization actions according to specified rules via a presigned URL.
const request: Sanitize.SanitizeRequest = {
transfer_method: TransferMethod.PUT_URL,
uploaded_file_name: "uploaded_file",
};
const presignedUrl = await sanitize.requestUploadURL(request);
// Upload file to `presignedUrl.accepted_result.put_url`.
// Poll for Sanitize's result.
const response = await sanitize.pollResult<Sanitize.SanitizeResult>(presignedUrl.request_id);
Sanitize
sanitize(request: SanitizeRequest, fileData: FileData, options: Options): Promise<PangeaResponse<SanitizeResult>>Apply file sanitization actions according to specified rules.
import { readFile } from "node:fs/promises";
const request: Sanitize.SanitizeRequest = {
transfer_method: TransferMethod.POST_URL,
uploaded_file_name: "uploaded_file",
};
const response = await sanitize.sanitize(
request,
{ file: await readFile("/path/to/file.pdf"), name: "filename" }
);