The File class provides the best way to access the File object. Most methods can be performed on the File object itself, including FileVersion methods.
$f = File::getByID($fileID)
Returns a file by ID. By default, this will return all version-specific information from the approved version of the file.
Returns a full path to the current file version.
Returns a clear text password if a file is password protected.
$fsID = $f->getFileStorageLocationID()
Returns an ID of a FileStorageLocation object for the current file.
Clears all cached information about a file, including the cache for all its versions.
Reindexes all custom attribute search information about a file.
$path = File::getRelativePathFromID($fileID)
A helper function. Get a relative path for a file ID.
Sets a files storage location. If $item == 0, the default storage location will be used. Otherwise, $item must equal a valid FileStorageLocation object.
Sets the password on a file object.
Resets permissions on a file object.
Returns true if a file has custom permissions set on it that override any file sets it happens to be in (only available when using advanced permissions.)
$f->setPermissions($obj, $canRead, $canSearch, $canWrite, $canAdmin)
Sets up a permissions record on the current File object. $obj may be an instance of the UserInfo or Group class. All arguments beginning with $can should be one of the following permissions levels:
Returns the user ID of the user who created the File object.
Sets the user ID of the File object.
$sets = $f->getFileSets()
Gets an array containing all FileSet objects in which the current File object appears.
$r = $f->isStarred($u = false)
Returns true if the file is starred, checking against the $u User/UserInfo object if provided, otherwise using the currently logged-in User.
Gets the date the file was added.
$fileVersion = $f->getVersionToModify($forceCreateNew = false)
Returns a file version object that is to be written to. Computes whether we can use the current most recent version, OR a new one should be created.
Returns the current ID of the file.
$fv = $f->getApprovedVersion()
Returns the FileVersion object corresponding to the File's approved version.
$fv = $f->getRecentVersion()
Returns the most recent FileVersion object for this file.
$fv = $f->getVersion($fvID)
Returns a FileVersion object based on its FileVersion ID.
$r = $f->inFileSet(FileSet $fs)
Queries the FileSet $fs and returns true if the current file exists within it.
Removes a file, including all of its versions. Unlinks all physical files from the storage location as well.
$fileVersions = $f->getVersionList()
Returns an array of all FileVersion objects owned by this file.
$r = $f->getDownloadStatistics()
Gets an associative array of download statistics for this file.
Increments the downloads table for the file, storing the currently logged-in user as the downloader.
The FileVersion object holds version-specific file data. Much of the data about files is, in fact, version-specific. For example, the same File object may hold completely different files, thumbnails, file types, etc... from one version to the next. For convenience, the File object will pass through any methods that it doesn't understand to its currently loaded FileVersion object.
Returns the file ID.
Returns the file version ID.
Returns the 12-digit numerical prefix which is used to store the file.
Returns the file's name.
Returns the title.
Returns the tags.
Returns the file's description.
Returns true if the file version is approved.
Returns a text string corresponding to the file's type.
$f = $fv->getFile()
Gets the FileVersion's File object.
$tags = $fv->getTagsList()
Returns an array of tags by parsing line breaks.
$attributes = $fv->getAttributeList()
Returns an associative array of all attributes for a FileVersion object.
$fv->getAttribute($ak, $mode = false)
Returns an attribute. $ak may either be an AttributeKey object or AttributeKey text handle.
Gets a file version's MIME type.
Returns a file version's size in kilobytes.
Returns the file size in bits.
Returns the username of the file version's author.
Returns the user ID of the file version's author.
Returns the date the File object was added. Specify 'user' for the type to convert the time into the user's timezone (ENABLE_USER_TIMEZONES must be enabled.)
Returns the extension of the file version.
$fv = $fv->duplicate()
Duplicates a file version, passing the new version back.
Gets the name of the file's type.
FileType $ft = $fv->getFileTypeObject()
Returns a FileType object for the current FileVersion.
$comments = $fv->getVersionLogComments()
Returns an array containing human-readable descriptions of everything that happened in this version
Updates the title of the current File version.
Updates the tags of the current File version.
Updates the description of the current File version.
Updates the file of the current file version.
Sets an attribute. $ak may be an instance of the AttributeKey object or an AttributeKey text handle.
Deletes a version of a file. Note, does NOT remove the physical file.
$path = $fv->getPath()
Returns a full filesystem path to the file on disk.
$url = $fv->getURL()
Returns a full URL to the file on disk.
$url = $fv->getDownloadURL()
Returns a URL that can be used to download the file. This passes through the download_file single page, which checks passwords, permissions, etc...
$url = $fv->getForceDownloadURL()
Returns a URL that can be used to download the file, and forces the download, i.e. images and PDFs won't attempt to display in-browser, they will always download. Also passes through the download_file single page, which checks passwords, permissions, etc...
$path = $fv->getRelativePath()
Gets a relative path to a file.
$path = $fv->getThumbnailPath($level)
Gets a full system path to a thumbnail. $level may be 1, 2 or 3.
$src = $fv->getThumbnailSRC($level)
Gets a relative path to a thumbnail. $level may be 1, 2 or 3.
$r = $fv->hasThumbnail($level)
Returns true if the FileVersion object has a thumbnail of that level.
$r = $fv->getThumbnail($level, $fullImageTag = true)
Returns a thumbnail if one is present, or a link to the file type's icon.
Returns true if this FileVersion's file type has a custom file viewer available to it (see the Metadata, Viewing & Editing section.)
Returns true if this FileVersion's file type has a custom file editor available to it (see the Metadata, Viewing & Editing section.)