Files
Learn about how Scan Documents handles file objects
Overview
The File object represents a file that has been uploaded to the Scan Documents API. This could be an image (like a PNG, JPEG, or WebP) or a document (currently, only PDF is supported).
Scan Documents API allows you to operate on these files, through Task Operations. Depending on the type of file, you can perform various operations such as converting, extracting text, or analyzing the content.
Example File Object
Here's what a typical File object representing a PNG image might look like:
Now, let's break down the properties of this File object.
Properties
Every File object, regardless of its type, will have the following basic information:
A unique identifier for the file (e.g., file_euyrvozb9302uwhq
). You'll use this ID to refer to the file in other API operations.
The name you gave the file when you uploaded it (e.g., Example image
).
The MIME type of the file (e.g., image/png
, application/pdf
). This tells you what kind of file it is.
An object containing additional properties specific to the file type. This will include details like size, dimensions, or page count.
If this file was generated as the result of an API operation (like converting an image), this field will contain the ID of that task. Otherwise, it will be null
.
The date and time when the file was uploaded or created, in ISO format (e.g., 2021-05-01T12:00:00Z
).
The properties
object will vary depending on the type of file. Below are the details for each supported file type.
Image Files
If the file is an image, the type
will be one of image/png
, image/jpeg
, or image/webp
.
The properties
object for an image will contain:
The file size in bytes (e.g., 1024
).
The width of the image in pixels (e.g., 800
).
The height of the image in pixels (e.g., 600
).
Example
Here's what a typical File object representing a PNG image might look like:
Document Files
If the file is a PDF document, the type
will be application/pdf
The properties
object for a document will contain:
The file size in bytes (e.g., 20480
).
The number of pages in the document (e.g., 10
).
Example
Here's what a typical File object representing a PDF document might look like:
File Operations
Now that you understand the File object, you can use it in various API operations. Check out the Task Operations section for more details on how to use files in your API requests.