Comprehensive file information object returned by getFileInfo methods. This interface provides detailed information about uploaded files, allowing pricing scripts to make decisions based on file characteristics such as size, type, dimensions, and content.

File information is essential for file-based pricing models where costs are calculated based on file properties rather than just product specifications.

Hierarchy

  • FileInfo

Properties

Content: string[]

Array of lines with the text file content. This array is only set when the readContent flag is set and the file size is smaller than the 50KB limitation. Used for content-based pricing.

Example

if (fileInfo.Content && fileInfo.Content.length > 0) {
var lineCount = fileInfo.Content.length;
return Item.Price + (lineCount * 0.005); // $0.005 per line
}
Dimensions: PageSize[]

Array of page size items, each having Width and Height properties. This array provides dimensional information for each page in the document, allowing for precise cost calculations based on page dimensions.

Example

var totalArea = 0;
for (var i = 0; i < fileInfo.Dimensions.length; i++) {
var page = fileInfo.Dimensions[i];
totalArea += page.Width * page.Height;
}
return Item.Price + (totalArea * 0.0001); // Cost based on total area
Error: string

Error message indicating any issues encountered during file processing. This value is empty if retrieving file information was successful. Used for error handling and debugging file processing issues.

Example

if (fileInfo.Error) {
error("File processing error: " + fileInfo.Error);
return Item.Price; // Fallback to base price
}
MimeType: string

The MIME type of the file. This value indicates the file format and type, allowing scripts to apply different pricing logic based on file type.

Example

if (fileInfo.MimeType === "application/pdf") {
return Item.Price + (fileInfo.NumberOfPages * 0.50); // $0.50 per page
} else if (fileInfo.MimeType.startsWith("image/")) {
return Item.Price + 2.00; // $2.00 for image files
}
NumberOfPages: number

The number of pages in the document. This value is only set for PDF attachments that can be parsed correctly and when the file size is within the 10 MB limitation. Used for page-based pricing models.

Example

if (fileInfo.NumberOfPages > 0) {
return Item.Price + (fileInfo.NumberOfPages * 0.25); // $0.25 per page
}
NumberOfRecords: number

The number of lines in a text/csv file. This value is only set when the readContent flag is set during file information retrieval. Used for line-based pricing models.

Example

if (fileInfo.NumberOfRecords > 0) {
return Item.Price + (fileInfo.NumberOfRecords * 0.01); // $0.01 per line
}
Size: number

The size of the file in bytes. This value is used for size-based pricing models and to determine processing costs based on file complexity.

Example

if (fileInfo.Size > 1024 * 1024) { // > 1MB
return Item.Price * 1.2; // 20% markup for large files
}

Generated using TypeDoc