Message-ID: <991887303.3888.1485855797875.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3887_1202655498.1485855797875" ------=_Part_3887_1202655498.1485855797875 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html The BinaryFile FieldType

The BinaryFile FieldType

This FieldType represents and handles = a binary file. It also counts the number of times the file has been downloa= ded from the content/download module.

Name Internal name Expected input Output
BinaryFile ezbinaryfile Mixed Mixed

Table of contents:

=20 =20

Description


This FieldType allows the storage and retrieval of a single= file. It is capable of handling virtually any file type and is typically u= sed for storing legacy document types such as PDF files, Word documents, sp= readsheets, etc. The maximum allowed file size is determined by the "Max fi= le size" class attribute edit parameter and the "upload_max_filesize<= /code>" directive in the main PHP configuration file ("php.ini").

BinaryFile Value= Object API


eZ\Publish\Core\FieldType\BinaryFile\Value offers the follo= wing properties.

Note that both BinaryFile and Media Value and Type inherit = from the BinaryBase abstract field type, and share common prop= erties.

Attribute Type Description Example
id string Binary file identifier. This= ID depends on the IO Handler that is being used. With the native, default= handlers (FileSystem and Legacy), the ID is the file path, relative to the= binary file storage root dir (var/<vardir>/storage/original by default). This attribute has been introduced in eZ Publish = 5.2. application/63cd472dd7819da7b75e8e= 2fee507c68.pdf
fileName string The human readable file name, as e= xposed to the outside. Used when sending the file for download in order to = name the file. 20130116_whitepaper_ezpublish5 lig= ht.pdf
fileSize int File size, in bytes 1077923
mimeType string The file's mime type. application/pdf
uri string

The binary file's HTTP uri. If = the URI doesn't include a host or protocol, it applies to the request domai= n. This attribute has been introduced in eZ Publish 5.2.

The URI is not publicly readable, and must NOT be used to link= to the file for download. Use ez_render_field to gen= erate a valid link to the download controller.

V5.4

Since v5.4 the pro= perty contains the binary file's content/download URL.

/var/ezdemo_site/storage/origin= al/application/63cd472dd7819da7b75e8e2fee507c68.pdf

V5.4 /content/download/2= 10/2707

downloadCount integer Number of times the file was downl= oaded 0
path string

*deprecated*
 Renamed to id starting from eZ Publish 5.2. Can still = be used, but it is recommended not to use it anymore as it will be removed.=

 

BinaryFile hash form= at


The hash format mostly matches the value object. It has the following ke= ys:

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 conten= t: 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= .

Example: http://example.com/var/ezdemo_site/storage/original/ap= plication/63cd472dd7819da7b75e8e2fee507c68.pdf

Creating con= tent: data property

When creating BinaryFile content with the REST API, it is possible to pr= ovide data as a base64 encoded string, using the "data" fieldV= alue key:

=20
<field>
    <fieldDefinitionIdentifier>file</fieldDefinitionIdentifier>
    <languageCode>eng-GB</languageCode>
    <fieldValue>
        <value key=3D"fileName">My file.pdf</value>
        <value key=3D"fileSize">17589</value>
        <value key=3D"data"><![CDATA[/9j/4AAQSkZJRgABAQEAZABkAAD/2=
wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcG
...
...]]></value>
    </fieldValue>
</field>
=20
------=_Part_3887_1202655498.1485855797875--