Date de publication: le mercredi 11 juillet 2007 à 23h15
Dernière modification: par Pascal BOYER le mercredi 23 février 2011 à 23h40
Summary / Résumé
Stores any type of file.
Stocke n'importe quel type de fichier.
Properties / Propriétés
|
Name Nom |
Internal name Nom interne |
Searchable Interrogeable |
Information collector Collecteur d'informations |
|---|---|---|---|
|
File Fichier | ezbinaryfile | Yes / Oui | No / Non |
Description
This datatype 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"). The following screenshot shows the class attribute edit interface for this datatype.
Ce datatype permet de stocker et de retrouver un unique fichier. Il peut virtuellement gérer n'importe quel type de fichier et est typiquement utilisé pour stocker des documents attachés comme les fichiers PDF, les document OOo, les feuilles de calcul, etc... La taille maximum autorisée des fichiers téléchargés est définie par le paramètre d'attribut de classe Taille maximum de fichier et par la directive upload_max_filesize du principal fichier de configuration de PHP, php.ini. La capture d'écran ci-dessous montre l'interface d'édition d'attribut de classe dans le cas de ce datatype:
Class attribute edit interface for the "File" datatype
Interface d'édition d'attribut de classe dans le cas du datatype Fichier
Max file size / Taille maximum de fichier
The "Max file size" parameter makes it possible to set the highest size (in megabytes) that the system will allow. By default, this parameters is zero, which means that eZ Publish will not do any size checking when files are uploaded. In the example above, the "Max file size" parameter is set to 16 MB, which means that the object edit interface will not allow the upload of files that are larger than 16 megabytes. However, if the value of the "upload_max_filesize" PHP setting is lower than 16 megabytes, the underlying system will cancel the upload.
Le paramètre Taille maximum de fichier sert à définir la taille maximum (en mégaoctet) des fichiers que le système autorise. Par défaut, ce paramètre vaut zéro, ce qui signifie que eZ Publish n'effectue aucun contrôle sur la taille des fichiers lors de leur téléchargement. Dans l'exemple ci-dessus, le paramètre Taille maximum de fichier vaut 16 MB, ce qui veut dire que l'interface d'édition d'objet n'autorise pas le téléchargement de fichiers dont la taille dépasse 16 mégaoctets. Cependant, si la valeur du paramètre upload_max_filesize du fichier de configuration php.ini de PHP est inférieur à 16 mégaoctets alors le système principal (fondamental) stoppera le téléchargement.
Object attribute edit interface / Interface d'édition d'attribut d'objet
The following screenshot shows the object attribute edit interface when an attribute using this datatype does not contain any file.
La capture d'écran ci-dessous montre l'interface d'édition d'attribut d'objet lorsqu'un attribut basé sur le datatype Fichier ne contient aucun fichier:
Object attribute edit interface for the "File" datatype
Interface d'édition d'attribut d'objet dans le cas du datatype Fichier
The following screenshot shows the object attribute edit interface when an attribute using this datatype contains a file. The interface reveals the name of the file that was uploaded ("BDScratch.wav"), the MIME type ("audio/wav") and the size (1.15 MB).
L'image suivante montre l'interface d'édition d'attribut d'objet lorsqu'un attribut basé sur le datatype Fichier contient un fichier: Cette interface affiche le nom du fichier téléchargé (BDScratch.wav), son type MIME (audio/wav) et sa taille (1.15 MB).
Object attribute edit interface for the "File" datatype
Interface d'édition d'attribut d'objet dans le cas du datatype Fichier
MIME types / Types MIME
The MIME type will be automatically set based on the extension of the uploaded file's name. If the extension is unknown, the default MIME type will be used ("application/octet-stream"). The MIME types can be configured at the end of the "/lib/ezutils/classes/ezmimetype.php" file.
Le paramétrage automatique du type MIME est basé sur l'extension du nom du fichier téléchargé. Si l'extension est inconnue, le type MIME par défaut est utilisé ( application/octet-stream). Enfin, les types MIME sont configurés à la fin du fichier /lib/ezutils/classes/ ezmimetype.php
Storage / Stockage
The uploaded files are stored on the file system. The main reason for this is because the file system is much faster than the database when it comes to the storage and retrieval of large data chunks. Having the files on the file system allows the web server to serve them directly without the need of going through the database. In addition, this technique makes it easier to use external tools to manipulate/scan/index the contents of the uploaded files and it dramatically decreases the size of the database.
Les fichiers téléchargés sont stockés sur le système de fichier car il est bien plus rapide que la base de données pour stocker et retrouver des données de taille conséquente. Le fait de placer les fichiers sur le système de fichiers permet au serveur web de les servir directement sans avoir besoin de les extraire de la base de données. De plus, cette technique simplifie l'emploi d'outils externes de manipulation/scan/indexation de contenu de fichiers téléchargés et évite que la taille de la base de données augmente dramatiquement.
All files uploaded through an attribute that makes use of the file datatype will be stored below "storage/original" within the directory specified by the "VarDir" directive in a configuration override for "site.ini". A new subdirectory will be created for every MIME type. For example, if an executable (.exe) file is uploaded, a directory called "application" will be created; if a text file is uploaded then a directory called "text" will be created, and so on. The uploaded files will be put in the different MIME type directories. Instead of re-using the original filenames, eZ Publish will create a hash for every file. The following illustration shows the location of two uploaded files (an .exe and a .txt file) when the var directory is set to "my_site".
Tous les fichiers téléchargés à partir d'un attribut basé sur le datatype Fichier sont stockées sous storage/original/ du répertoire défini par le paramètre VarDir d'un fichier de surcharge de site.ini. Un nouveau sous-répertoire est crée pour chaque type MIME. Par exemple, si un exécutable ( .exe) est téléchargé, alors un sous-répertoire nommé application sera créé. De même, pour un fichier texte, le répertoire créé se nommera text. Et ainsi de suite. Les fichiers téléchargés sont placés dans les différents répertoires de type MIME et plutôt que d'utiliser le nom original du fichier, eZ Publish crée un tableau associatif (hash) pour chaque nouveau fichier. L'illustration suivante montre l'emplacement de deux fichiers téléchargés (un fichier .exe et un .txt) lorsque le paramètre VarDir vaut my_site:
Complete directory structure with uploaded files
Structure arborescente complète avec les fichiers téléchargés
The system keeps track of the files using a database table called "ezbinaryfile" consisting of the following fields:
Le système conserve une trace des fichiers dans la table ezbinaryfile de la base de données. Cette table est composée des champs suivants:
| Field / Champ | Description |
|---|---|
| content_object_attribute_id |
The identification of the content object attribute. L'identification de l'attribut de l'objet de contenu. |
| download_count |
The number of times the file has been downloaded. Le nombre de fois qu'un fichier a été téléchargé. |
| filename |
The name of the file on the filesystem (for example "5fd39fbaf751369965a4108715d5dea9.txt"). Le nom du fichier sur le système de fichier (par exemple 5fd39fbaf751369965a4108715d5dea9.txt). |
| mime_type |
The MIME type of the file (for example "text/plain"). Le type MIME du fichier (par exemple text/plain). |
| original_filename |
The original name of the uploaded file (for example "readme.txt"). Le nom original du fichier téléchargé (par exemple readme.txt). |
| version |
The version of the object that the file belongs to. La version de l'objet à laquelle appartient le fichier. |
Binary file indexing / Indexation d'un fichier binaire
eZ Publish is capable of indexing the actual contents of uploaded files. This feature makes it possible to use the built-in search engine to search for something that is inside a file; for example the contents of a PDF file or a spreadsheet. By default, the system is only capable of indexing the contents of plain text/ASCII files. However, by making use of external programs, it is capable of indexing the contents of virtually any file type (as long as there is a program that goes through the file and returns keywords/contents as plain text). The external handlers can be set up in a configuration override for the "binaryfile.ini" file.
eZ Publish indexe les contenus des fichiers téléchargés. Cette fonction fait usage du moteur de recherche interne pour chercher quelque chose contenu par un fichier, comme par exemple le contenu d'un fichier PDF ou d'une feuille de calcul. Par défaut, le système n'est capable d'indexer que le contenu des fichiers text/ASCII. Cependant, grâce à l'emploi de logiciels externes, il est virtuellement possible d'indexer n'importe quel type de fichier (tant qu'il existe un programme capable de parcourir le fichier et de retourner des mots clef ou du contenu au format plain text). Les gestionnaires externes peuvent être configurer dans une surcharge du fichier de configuration binaryfile.ini.
Raw output / Sortie brute
The ".content" of an ezcontentobjectattribute object using this datatype returns an ezbinaryfile object.
La partie .content d'un objet
ezcontentobjectattribute
utilisant un attribut basé sur ce datatype renvoie un objet
ezbinaryfile
.














