This FieldType represents and handles a binary file. It also counts the number of times the file has been downloaded from the
|Name||Internal name||Expected input||Output|
FieldType allows the storage and retrieval of a single file. It is capable of handling virtually any file type and is typically used for storing legacy document types such as PDF files, Word documents, spreadsheets, etc. The maximum allowed file size is determined by the "Max file size" class attribute edit parameter and the "
upload_max_filesize" directive in the main PHP configuration file ("php.ini").
BinaryFile Value Object API
eZ\Publish\Core\FieldType\BinaryFile\Value offers the following properties.
Note that both
BinaryFile and Media Value and Type inherit from the
BinaryBase abstract field type, and share common properties.
|string||The human readable file name, as exposed to the outside. Used when sending the file for download in order to name the file.||20130116_whitepaper_ezpublish5 light.pdf|
|int||File size, in bytes||1077923|
|string||The file's mime type.||application/pdf|
|integer||Number of times the file was downloaded||0|
BinaryFile hash format
The hash format mostly matches the value object. It has the following keys:
REST API specifics
Used in the REST API, a BinaryFile field will mostly serialize the hash described above. However there are a couple specifics worth mentioning.
Reading content: url property
When reading the contents of a field of this type, an extra key is added: url. This key gives you the absolute file URL, protocol and host included.
Creating content: data property
When creating BinaryFile content with the REST API, it is possible to provide data as a base64 encoded string, using the "
data" fieldValue key: