Page MenuHomenazrin ltd
Diviner Tech Docs PhabricatorFile

final class PhabricatorFile
Phorge Technical Documentation (Files)

Parameters

When creating a new file using a method like newFromFileData(), these parameters are supported:

| name | Human readable filename.
| authorPHID | User PHID of uploader.
| ttl.absolute | Temporary file lifetime as an epoch timestamp.
| ttl.relative | Temporary file lifetime, relative to now, in seconds.
| viewPolicy | File visibility policy.
| isExplicitUpload | Used to show users files they explicitly uploaded.
| canCDN | Allows the file to be cached and delivered over a CDN.
| profile | Marks the file as a profile image.
| format | Internal encoding format.
| mime-type | Optional, explicit file MIME type.
| builtin | Optional filename, identifies this as a builtin.

Methods

public function getApplicationName()
Inherited

This method is not documented.
Return
wild

public static function initializeNewFile()

This method is not documented.
Return
wild

protected function getConfiguration()

This method is not documented.
Return
wild

public function generatePHID()

This method is not documented.
Return
wild

public function save()

This method is not documented.
Return
wild

public function saveAndIndex()

This method is not documented.
Return
wild

private function isIndexableFile()

This method is not documented.
Return
wild

public function getMonogram()

Get file monogram in the format of "F123"

Return
string

public function scrambleSecret()

This method is not documented.
Return
wild

public static function readUploadedFileData($spec)

This method is not documented.
Parameters
$spec
Return
wild

public static function newFromPHPUpload($spec, $params)

This method is not documented.
Parameters
$spec
array$params
Return
wild

public static function newFromXHRUpload($data, $params)

This method is not documented.
Parameters
$data
array$params
Return
wild

public static function newFileFromContentHash($hash, $params)

This method is not documented.
Parameters
$hash
array$params
Return
wild

public static function newChunkedFile($engine, $length, $params)

This method is not documented.
Parameters
PhabricatorFileStorageEngine$engine
$length
array$params
Return
wild

private static function buildFromFileData($data, $params)

This method is not documented.
Parameters
$data
array$params
Return
wild

public static function newFromFileData($data, $params)

This method is not documented.
Parameters
$data
array$params
Return
wild

public function migrateToEngine($engine, $make_copy)

This method is not documented.
Parameters
PhabricatorFileStorageEngine$engine
$make_copy
Return
wild

public function migrateToStorageFormat($format)

This method is not documented.
Parameters
PhabricatorFileStorageFormat$format
Return
wild

public function cycleMasterStorageKey($format)

This method is not documented.
Parameters
PhabricatorFileStorageFormat$format
Return
wild

private function writeToEngine($engine, $data, $params)

This method is not documented.
Parameters
PhabricatorFileStorageEngine$engine
$data
array$params
Return
wild

public static function newFromFileDownload($uri, $params)

Download a remote resource over HTTP and save the response body as a file.

This method respects security.outbound-blacklist, and protects against HTTP redirection (by manually following "Location" headers and verifying each destination). It does not protect against DNS rebinding. See discussion in T6755.

Parameters
$uri
array$params
Return
wild

public static function normalizeFileName($file_name)

This method is not documented.
Parameters
$file_name
Return
wild

public function delete()

This method is not documented.
Return
wild

public function deleteFileDataIfUnused($engine, $engine_identifier, $handle)

Destroy stored file data if there are no remaining files which reference it.

Parameters
PhabricatorFileStorageEngine$engine
$engine_identifier
$handle
Return
wild

public static function hashFileContent($data)

This method is not documented.
Parameters
$data
Return
wild

public function loadFileData()

This method is not documented.
Return
wild

public function getFileDataIterator($begin, $end)

Return an iterable which emits file content bytes.

Parameters
int$beginOffset for the start of data.
int$endOffset for the end of data.
Return
IterableIterable object which emits requested data.

public function getURI()

Get file URI in the format of "/F123"

Return
string

public function getViewURI()

Return
string

public function getCDNURI($request_kind)

Parameters
$request_kind
Return
string

public function getInfoURI()

Get file info URI in the format of "/F123"

Return
string

public function getBestURI()

This method is not documented.
Return
wild

public function getDownloadURI()

Return
string

public function getURIForTransform($transform)

This method is not documented.
Parameters
PhabricatorFileTransform$transform
Return
wild

private function getTransformedURI($transform)

This method is not documented.
Parameters
$transform
Return
wild

public function isViewableInBrowser()

Whether the file can be viewed in a browser

Return
boolTrue if MIME type of the file is listed in the files.viewable-mime-types setting

public function isViewableImage()

Whether the file is an image viewable in the browser

Return
boolTrue if MIME type of the file is listed in the files.image-mime-types setting and file is viewable in the browser

public function isAudio()

Whether the file is an audio file

Return
boolTrue if MIME type of the file is listed in the files.audio-mime-types setting and file is viewable in the browser

public function isVideo()

Whether the file is a video file

Return
boolTrue if MIME type of the file is listed in the files.video-mime-types setting and file is viewable in the browser

public function isPDF()

Whether the file is a PDF file

Return
boolTrue if MIME type of the file is application/pdf and file is viewable in the browser

public function isTransformableImage()

This method is not documented.
Return
wild

public static function getTransformableImageFormats()

This method is not documented.
Return
wild

public function getDragAndDropDictionary()

This method is not documented.
Return
wild

public function instantiateStorageEngine()

This method is not documented.
Return
wild

public static function buildEngine($engine_identifier)

This method is not documented.
Parameters
$engine_identifier
Return
wild

public static function buildAllEngines()

This method is not documented.
Return
wild

public function getViewableMimeType()

Whether the file is listed as a viewable MIME type

Return
boolTrue if MIME type of the file is listed in the files.viewable-mime-types setting

public function getDisplayIconForMimeType()

This method is not documented.
Return
wild

public function validateSecretKey($key)

This method is not documented.
Parameters
$key
Return
wild

public function generateSecretKey()

This method is not documented.
Return
wild

public function setStorageProperties($properties)

This method is not documented.
Parameters
array$properties
Return
wild

public function getStorageProperties()

This method is not documented.
Return
wild

public function getStorageProperty($key, $default)

This method is not documented.
Parameters
$key
$default
Return
wild

public function loadDataFromIterator($iterator)

This method is not documented.
Parameters
$iterator
Return
wild

public function updateDimensions($save)

This method is not documented.
Parameters
$save
Return
wild

public function copyDimensions($file)

This method is not documented.
Parameters
PhabricatorFile$file
Return
wild

public static function loadBuiltins($user, $builtins)

Load (or build) the {@class:PhabricatorFile} objects for builtin file resources. The builtin mechanism allows files shipped with Phabricator to be treated like normal files so that APIs do not need to special case things like default images or deleted files.

Builtins are located in resources/builtin/ and identified by their name.

Parameters
PhabricatorUser$userViewing user.
list<PhabricatorFilesBuiltinFile>$builtinsList of builtin file specs.
Return
dict<string, PhabricatorFile>Dictionary of named builtins.

public static function loadBuiltin($user, $name)

Convenience wrapper for loadBuiltins().

Parameters
PhabricatorUser$userViewing user.
string$nameSingle builtin name to load.
Return
PhabricatorFileCorresponding builtin file.

public function getObjects()

This method is not documented.
Return
wild

public function attachObjects($objects)

This method is not documented.
Parameters
array$objects
Return
wild

public function getObjectPHIDs()

This method is not documented.
Return
wild

public function attachObjectPHIDs($object_phids)

This method is not documented.
Parameters
array$object_phids
Return
wild

public function getOriginalFile()

This method is not documented.
Return
wild

public function attachOriginalFile($file)

This method is not documented.
Parameters
PhabricatorFile$file
Return
wild

public function getImageHeight()

This method is not documented.
Return
wild

public function getImageWidth()

This method is not documented.
Return
wild

public function getAltText()

This method is not documented.
Return
wild

public function getCustomAltText()

This method is not documented.
Return
wild

public function setCustomAltText($value)

This method is not documented.
Parameters
$value
Return
wild

public function getDefaultAltText()

This method is not documented.
Return
wild

public function getCanCDN()

This method is not documented.
Return
wild

public function setCanCDN($can_cdn)

This method is not documented.
Parameters
$can_cdn
Return
wild

public function isBuiltin()

This method is not documented.
Return
wild

public function getBuiltinName()

This method is not documented.
Return
wild

public function setBuiltinName($name)

This method is not documented.
Parameters
$name
Return
wild

public function getIsProfileImage()

This method is not documented.
Return
wild

public function setIsProfileImage($value)

This method is not documented.
Parameters
$value
Return
wild

public function getIsChunk()

This method is not documented.
Return
wild

public function setIsChunk($value)

This method is not documented.
Parameters
$value
Return
wild

public function setIntegrityHash($integrity_hash)

This method is not documented.
Parameters
$integrity_hash
Return
wild

public function getIntegrityHash()

This method is not documented.
Return
wild

public function newIntegrityHash()

This method is not documented.
Return
wild

public function attachToObject($phid)

Write the policy edge between this file and some object. This method is successful even if the file is already attached.

Parameters
phid$phidObject PHID to attach to.
Return
this

public static function attachFileToObject($file_phid, $object_phid)

Write the policy edge between a file and some object. This method is successful even if the file is already attached.

NOTE: Please avoid to use this static method directly. Instead, use PhabricatorFile#attachToObject(phid).
Parameters
phid$file_phidFile PHID to attach from.
phid$object_phidObject PHID to attach to.
Return
void

private function readPropertiesFromParameters($params)

Configure a newly created file object according to specified parameters.

This method is called both when creating a file from fresh data, and when creating a new file which reuses existing storage.

Parameters
map<string,$paramswild> Bag of parameters, see @{class:PhabricatorFile} for documentation.
Return
this

public function getRedirectResponse()

This method is not documented.
Return
wild

public function newDownloadResponse()

This method is not documented.
Return
wild

public function attachTransforms($map)

This method is not documented.
Parameters
array$map
Return
wild

public function getTransform($key)

This method is not documented.
Parameters
$key
Return
wild

public function newStorageFormat()

This method is not documented.
Return
wild
This method is not documented.
Return
wild
This method is not documented.
Return
wild

public function getCapabilities()

This method is not documented.
Return
wild

public function getPolicy($capability)

This method is not documented.
Parameters
$capability
Return
wild

public function hasAutomaticCapability($capability, $viewer)

This method is not documented.
Parameters
$capability
PhabricatorUser$viewer
Return
wild

public function describeAutomaticCapability($capability)

This method is not documented.
Parameters
$capability
Return
wild

public function isAutomaticallySubscribed($phid)

This method is not documented.
Parameters
$phid
Return
wild
This method is not documented.
Return
wild

public function destroyObjectPermanently($engine)

This method is not documented.
Parameters
PhabricatorDestructionEngine$engine
Return
wild
This method is not documented.
Return
wild

public function getFieldValuesForConduit()

This method is not documented.
Return
wild

public function getConduitSearchAttachments()

This method is not documented.
Return
wild

public function newNgrams()

This method is not documented.
Return
wild