Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
file_storage Class Reference

Public Member Functions

 __construct ()
 Constructor - do not use directly use get_file_storage() call instead.
 
 add_file_to_pool ($pathname, $contenthash=null, $newrecord=null)
 Add file content to sha1 pool. More...
 
 add_string_to_pool ($content, $newrecord=null)
 Add string content to sha1 pool. More...
 
 content_exists ($contenthash)
 Content exists. More...
 
 convert_image ($filerecord, $fid, $newwidth=null, $newheight=null, $keepaspectratio=true, $quality=null)
 Creates new image file from existing. More...
 
 create_directory ($contextid, $component, $filearea, $itemid, $filepath, $userid=null)
 Recursively creates directory. More...
 
 create_file_from_pathname ($filerecord, $pathname)
 Add new local file. More...
 
 create_file_from_reference ($filerecord, $repositoryid, $reference, $options=array())
 Create a new alias/shortcut file from file reference information. More...
 
 create_file_from_storedfile ($filerecord, $fileorid)
 Add new local file based on existing local file. More...
 
 create_file_from_string ($filerecord, $content)
 Add new local file. More...
 
 create_file_from_url ($filerecord, $url, array $options=null, $usetempfile=false)
 Add new local file. More...
 
 cron ()
 Cron cleanup job.
 
 delete_area_files ($contextid, $component=false, $filearea=false, $itemid=false)
 Delete all area files (optionally limited by itemid). More...
 
 delete_area_files_select ($contextid, $component, $filearea, $itemidstest, array $params=null)
 Delete all the files from certain areas where itemid is limited by an arbitrary bit of SQL. More...
 
 delete_component_files ($component)
 Delete all files associated with the given component. More...
 
 file_exists ($contextid, $component, $filearea, $itemid, $filepath, $filename)
 Does this file exist? More...
 
 file_exists_by_hash ($pathnamehash)
 Whether or not the file exist. More...
 
 get_area_files ($contextid, $component, $filearea, $itemid=false, $sort="itemid, filepath, filename", $includedirs=true, $updatedsince=0, $limitfrom=0, $limitnum=0)
 Returns all area files (optionally limited by itemid) More...
 
 get_area_tree ($contextid, $component, $filearea, $itemid)
 Returns array based tree structure of area files. More...
 
 get_converted_document (stored_file $file, $format, $forcerefresh=false)
 Get converted document. More...
 
 get_directory_files ($contextid, $component, $filearea, $itemid, $filepath, $recursive=false, $includedirs=true, $sort="filepath, filename")
 Returns all files and optionally directories. More...
 
 get_external_files ($repositoryid, $sort='')
 Returns all files belonging to given repository. More...
 
 get_file ($contextid, $component, $filearea, $itemid, $filepath, $filename)
 Fetch locally stored file. More...
 
 get_file_by_hash ($pathnamehash)
 Fetch file using local file full pathname hash. More...
 
 get_file_by_id ($fileid)
 Fetch file using local file id. More...
 
 get_file_instance (stdClass $filerecord)
 Create instance of file class from database record. More...
 
 get_file_preview (stored_file $file, $mode)
 Returns an image file that represent the given stored file as a preview. More...
 
 get_file_system ()
 Return the file system instance. More...
 
 get_references_by_storedfile (stored_file $storedfile)
 Returns all aliases that link to the given stored_file. More...
 
 get_references_count_by_storedfile (stored_file $storedfile)
 Returns the number of aliases that link to the given stored_file. More...
 
 get_unused_dirname ($contextid, $component, $filearea, $itemid, $suggestedpath)
 Return an available directory name. More...
 
 get_unused_filename ($contextid, $component, $filearea, $itemid, $filepath, $filename)
 Return an available file name. More...
 
 import_external_file (stored_file $storedfile, $maxbytes=0)
 Convert file alias to local file. More...
 
 is_area_empty ($contextid, $component, $filearea, $itemid=false, $ignoredirs=true)
 Are there any files (or directories) More...
 
 move_area_files_to_new_context ($oldcontextid, $newcontextid, $component, $filearea, $itemid=false)
 Move all the files in a file area from one context to another. More...
 
 search_references ($reference)
 Returns all aliases that refer to some stored_file via the given reference. More...
 
 search_references_count ($reference)
 Returns the number of aliases that refer to some stored_file via the given reference. More...
 
 search_server_files ($query, $from=0, $limit=20, $count=false)
 Search through the server files. More...
 
 setup_file_system ()
 Complete setup procedure for the file_system component. More...
 
 supports_xsendfile ()
 Returns true if filesystem is configured to support xsendfile. More...
 
 synchronise_stored_file_from_file (stored_file $file, $path, $filerecord)
 Synchronise stored file from file. More...
 
 synchronise_stored_file_from_string (stored_file $file, $content, $filerecord)
 Synchronise stored file from string. More...
 
 try_content_recovery ($file)
 Tries to recover missing content of file from trash. More...
 
 update_references ($referencefileid, $lastsync, $lifetime, $contenthash, $filesize, $status, $timemodified=null)
 Updates a reference to the external resource and all files that use it. More...
 
 update_references_to_storedfile (stored_file $storedfile)
 Updates all files that are referencing this file with the new contenthash and filesize. More...
 
 xsendfile ($contenthash)
 Serve file content using X-Sendfile header. More...
 

Static Public Member Functions

static can_convert_documents ()
 Check if the installed version of unoconv is supported. More...
 
static get_pathname_hash ($contextid, $component, $filearea, $itemid, $filepath, $filename)
 Calculates sha1 hash of unique full path name information. More...
 
static hash_from_path ($filepath)
 Calculate and return the contenthash of the supplied file. More...
 
static hash_from_string ($content)
 Calculate and return the contenthash of the supplied content. More...
 
static mimetype ($fullpath, $filename=null)
 Return mimetype by given file pathname. More...
 
static mimetype_from_file ($fullpath)
 Inspect a file on disk for it's mimetype. More...
 
static pack_reference ($params)
 When user referring to a moodle file, we build the reference field. More...
 
static send_test_pdf ()
 Regenerate the test pdf and send it direct to the browser.
 
static test_unoconv_path ()
 Check if unoconv configured path is correct and working. More...
 
static unpack_reference ($str, $cleanparams=false)
 Unpack reference field. More...
 

Protected Member Functions

 call_before_file_created_plugin_functions ($newrecord, $pathname=null, $content=null)
 before_file_created hook. More...
 
 create_file ($newrecord)
 Add new file record to database and handle callbacks. More...
 
 create_file_preview (stored_file $file, $mode)
 Generates a preview image for the stored file. More...
 
 create_imagefile_preview (stored_file $file, $mode)
 Generates a preview for the stored image file. More...
 
 is_format_supported_by_unoconv ($format)
 Verify the format is supported. More...
 
 sort_area_tree ($tree)
 Sorts the result of file_storage::get_area_tree(). More...
 

Member Function Documentation

◆ add_file_to_pool()

file_storage::add_file_to_pool (   $pathname,
  $contenthash = null,
  $newrecord = null 
)

Add file content to sha1 pool.

Parameters
string$pathnamepath to file
string | null$contenthashsha1 hash of content if known (performance only)
stdClass | null$newrecordNew file record
Return values
array(contenthash, filesize, newfile)

◆ add_string_to_pool()

file_storage::add_string_to_pool (   $content,
  $newrecord = null 
)

Add string content to sha1 pool.

Parameters
string$contentfile content - binary string
Return values
array(contenthash, filesize, newfile)

◆ call_before_file_created_plugin_functions()

file_storage::call_before_file_created_plugin_functions (   $newrecord,
  $pathname = null,
  $content = null 
)
protected

before_file_created hook.

Parameters
stdClass | null$newrecordNew file record.
string | null$pathnamePath to file.
string | null$contentFile content.

◆ can_convert_documents()

static file_storage::can_convert_documents ( )
static

Check if the installed version of unoconv is supported.

Return values
booltrue if the present version is supported, false otherwise.

◆ content_exists()

file_storage::content_exists (   $contenthash)

Content exists.

Parameters
string$contenthash
Return values
bool
Deprecated:
since 3.3

◆ convert_image()

file_storage::convert_image (   $filerecord,
  $fid,
  $newwidth = null,
  $newheight = null,
  $keepaspectratio = true,
  $quality = null 
)

Creates new image file from existing.

Parameters
stdClass | array$filerecordobject or array describing new file
int | stored_file$fidfile id or stored file object
int$newwidthin pixels
int$newheightin pixels
bool$keepaspectratiowhether or not keep aspect ratio
int$qualitydepending on image type 0-100 for jpeg, 0-9 (0 means no compression) for png
Return values
stored_file

◆ create_directory()

file_storage::create_directory (   $contextid,
  $component,
  $filearea,
  $itemid,
  $filepath,
  $userid = null 
)

Recursively creates directory.

Parameters
int$contextidcontext ID
string$componentcomponent
string$fileareafile area
int$itemiditem ID
string$filepathfile path
int$useridthe user ID
Return values
boolsuccess

◆ create_file()

file_storage::create_file (   $newrecord)
protected

Add new file record to database and handle callbacks.

Parameters
stdClass$newrecord

◆ create_file_from_pathname()

file_storage::create_file_from_pathname (   $filerecord,
  $pathname 
)

Add new local file.

Parameters
stdClass | array$filerecordobject or array describing file
string$pathnamepath to file or content of file
Return values
stored_file

◆ create_file_from_reference()

file_storage::create_file_from_reference (   $filerecord,
  $repositoryid,
  $reference,
  $options = array() 
)

Create a new alias/shortcut file from file reference information.

Parameters
stdClass | array$filerecordobject or array describing the new file
int$repositoryidthe id of the repository that provides the original file
string$referencethe information required by the repository to locate the original file
array$optionsoptions for creating the new file
Return values
stored_file

◆ create_file_from_storedfile()

file_storage::create_file_from_storedfile (   $filerecord,
  $fileorid 
)

Add new local file based on existing local file.

Parameters
stdClass | array$filerecordobject or array describing changes
stored_file | int$fileoridid or stored_file instance of the existing local file
Return values
stored_fileinstance of newly created file

◆ create_file_from_string()

file_storage::create_file_from_string (   $filerecord,
  $content 
)

Add new local file.

Parameters
stdClass | array$filerecordobject or array describing file
string$contentcontent of file
Return values
stored_file

◆ create_file_from_url()

file_storage::create_file_from_url (   $filerecord,
  $url,
array  $options = null,
  $usetempfile = false 
)

Add new local file.

Parameters
stdClass | array$filerecordobject or array describing file
string$urlthe URL to the file
array$optionsdownload_file_content() options
bool$usetempfileuse temporary file for download, may prevent out of memory problems
Return values
stored_file

◆ create_file_preview()

file_storage::create_file_preview ( stored_file  $file,
  $mode 
)
protected

Generates a preview image for the stored file.

Parameters
stored_file$filethe file we want to preview
string$modepreview mode, eg. 'thumb'
Return values
stored_file|boolthe newly created preview file or false

◆ create_imagefile_preview()

file_storage::create_imagefile_preview ( stored_file  $file,
  $mode 
)
protected

Generates a preview for the stored image file.

Parameters
stored_file$filethe image we want to preview
string$modepreview mode, eg. 'thumb'
Return values
string|boolfalse if a problem occurs, the thumbnail image data otherwise

◆ delete_area_files()

file_storage::delete_area_files (   $contextid,
  $component = false,
  $filearea = false,
  $itemid = false 
)

Delete all area files (optionally limited by itemid).

Parameters
int$contextidcontext ID
string$componentcomponent
string$fileareafile area or all areas in context if not specified
int$itemiditem ID or all files if not specified
Return values
boolsuccess

◆ delete_area_files_select()

file_storage::delete_area_files_select (   $contextid,
  $component,
  $filearea,
  $itemidstest,
array  $params = null 
)

Delete all the files from certain areas where itemid is limited by an arbitrary bit of SQL.

Parameters
int$contextidthe id of the context the files belong to. Must be given.
string$componentthe owning component. Must be given.
string$fileareathe file area name. Must be given.
string$itemidstestan SQL fragment that the itemid must match. Used in the query like WHERE itemid $itemidstest. Must used named parameters, and may not used named parameters called contextid, component or filearea.
array$paramsany query params used by $itemidstest.

◆ delete_component_files()

file_storage::delete_component_files (   $component)

Delete all files associated with the given component.

Parameters
string$componentthe component owning the file

◆ file_exists()

file_storage::file_exists (   $contextid,
  $component,
  $filearea,
  $itemid,
  $filepath,
  $filename 
)

Does this file exist?

Parameters
int$contextidcontext ID
string$componentcomponent
string$fileareafile area
int$itemiditem ID
string$filepathfile path
string$filenamefile name
Return values
bool

◆ file_exists_by_hash()

file_storage::file_exists_by_hash (   $pathnamehash)

Whether or not the file exist.

Parameters
string$pathnamehashpath name hash
Return values
bool

◆ get_area_files()

file_storage::get_area_files (   $contextid,
  $component,
  $filearea,
  $itemid = false,
  $sort = "itemid, filepath, filename",
  $includedirs = true,
  $updatedsince = 0,
  $limitfrom = 0,
  $limitnum = 0 
)

Returns all area files (optionally limited by itemid)

Parameters
int$contextidcontext ID
string$componentcomponent
mixed$fileareafile area/s, you cannot specify multiple fileareas as well as an itemid
int | int[] | false$itemiditem ID(s) or all files if not specified
string$sortA fragment of SQL to use for sorting
bool$includedirswhether or not include directories
int$updatedsincereturn files updated since this time
int$limitfromreturn a subset of records, starting at this point (optional).
int$limitnumreturn a subset comprising this many records in total (optional, required if $limitfrom is set).
Return values
stored_file[]array of stored_files indexed by pathanmehash

◆ get_area_tree()

file_storage::get_area_tree (   $contextid,
  $component,
  $filearea,
  $itemid 
)

Returns array based tree structure of area files.

Parameters
int$contextidcontext ID
string$componentcomponent
string$fileareafile area
int$itemiditem ID
Return values
arrayeach dir represented by dirname, subdirs, files and dirfile array elements

◆ get_converted_document()

file_storage::get_converted_document ( stored_file  $file,
  $format,
  $forcerefresh = false 
)

Get converted document.

Get an alternate version of the specified document, if it is possible to convert.

Parameters
stored_file$filethe file we want to preview
string$formatThe desired format - e.g. 'pdf'. Formats are specified by file extension.
boolean$forcerefreshIf true, the file will be converted every time (not cached).
Return values
stored_file|boolfalse if unable to create the conversion, stored file otherwise

◆ get_directory_files()

file_storage::get_directory_files (   $contextid,
  $component,
  $filearea,
  $itemid,
  $filepath,
  $recursive = false,
  $includedirs = true,
  $sort = "filepath, filename" 
)

Returns all files and optionally directories.

Parameters
int$contextidcontext ID
string$componentcomponent
string$fileareafile area
int$itemiditem ID
int$filepathdirectory path
bool$recursiveinclude all subdirectories
bool$includedirsinclude files and directories
string$sortA fragment of SQL to use for sorting
Return values
arrayof stored_files indexed by pathanmehash

◆ get_external_files()

file_storage::get_external_files (   $repositoryid,
  $sort = '' 
)

Returns all files belonging to given repository.

Parameters
int$repositoryid
string$sortA fragment of SQL to use for sorting

◆ get_file()

file_storage::get_file (   $contextid,
  $component,
  $filearea,
  $itemid,
  $filepath,
  $filename 
)

Fetch locally stored file.

Parameters
int$contextidcontext ID
string$componentcomponent
string$fileareafile area
int$itemiditem ID
string$filepathfile path
string$filenamefile name
Return values
stored_file|boolstored_file instance if exists, false if not

◆ get_file_by_hash()

file_storage::get_file_by_hash (   $pathnamehash)

Fetch file using local file full pathname hash.

Parameters
string$pathnamehashpath name hash
Return values
stored_file|boolstored_file instance if exists, false if not

◆ get_file_by_id()

file_storage::get_file_by_id (   $fileid)

Fetch file using local file id.

Please do not rely on file ids, it is usually easier to use pathname hashes instead.

Parameters
int$fileidfile ID
Return values
stored_file|boolstored_file instance if exists, false if not

◆ get_file_instance()

file_storage::get_file_instance ( stdClass  $filerecord)

Create instance of file class from database record.

Parameters
stdClass$filerecordrecord from the files table left join files_reference table
Return values
stored_fileinstance of file abstraction class

◆ get_file_preview()

file_storage::get_file_preview ( stored_file  $file,
  $mode 
)

Returns an image file that represent the given stored file as a preview.

At the moment, only GIF, JPEG and PNG files are supported to have previews. In the future, the support for other mimetypes can be added, too (eg. generate an image preview of PDF, text documents etc).

Parameters
stored_file$filethe file we want to preview
string$modepreview mode, eg. 'thumb'
Return values
stored_file|boolfalse if unable to create the preview, stored file otherwise

◆ get_file_system()

file_storage::get_file_system ( )

Return the file system instance.

Return values
file_system

◆ get_pathname_hash()

static file_storage::get_pathname_hash (   $contextid,
  $component,
  $filearea,
  $itemid,
  $filepath,
  $filename 
)
static

Calculates sha1 hash of unique full path name information.

This hash is a unique file identifier - it is used to improve performance and overcome db index size limits.

Parameters
int$contextidcontext ID
string$componentcomponent
string$fileareafile area
int$itemiditem ID
string$filepathfile path
string$filenamefile name
Return values
stringsha1 hash

◆ get_references_by_storedfile()

file_storage::get_references_by_storedfile ( stored_file  $storedfile)

Returns all aliases that link to the given stored_file.

Aliases in user draft areas are excluded from the returned list.

Parameters
stored_file$storedfile
Return values
arrayof stored_file

◆ get_references_count_by_storedfile()

file_storage::get_references_count_by_storedfile ( stored_file  $storedfile)

Returns the number of aliases that link to the given stored_file.

Aliases in user draft areas are not counted.

Parameters
stored_file$storedfile
Return values
int

◆ get_unused_dirname()

file_storage::get_unused_dirname (   $contextid,
  $component,
  $filearea,
  $itemid,
  $suggestedpath 
)

Return an available directory name.

This will return the next available directory name in the area, adding/incrementing a suffix of the last portion of path, ie: /path/ > /path (1)/ > /path (2)/ > etc...

If the file path passed is available without modification, it is returned as is.

Parameters
int$contextidcontext ID.
string$componentcomponent.
string$fileareafile area.
int$itemidarea item ID.
string$suggestedpaththe suggested file path.
Return values
stringavailable file path
Since
Moodle 2.5

◆ get_unused_filename()

file_storage::get_unused_filename (   $contextid,
  $component,
  $filearea,
  $itemid,
  $filepath,
  $filename 
)

Return an available file name.

This will return the next available file name in the area, adding/incrementing a suffix of the file, ie: file.txt > file (1).txt > file (2).txt > etc...

If the file name passed is available without modification, it is returned as is.

Parameters
int$contextidcontext ID.
string$componentcomponent.
string$fileareafile area.
int$itemidarea item ID.
string$filepaththe file path.
string$filenamethe file name.
Return values
stringavailable file name.
Exceptions
coding_exceptionif the file name is invalid.
Since
Moodle 2.5

◆ hash_from_path()

static file_storage::hash_from_path (   $filepath)
static

Calculate and return the contenthash of the supplied file.

Parameters
string$filepathThe path to the file on disk
Return values
stringThe file's content hash

◆ hash_from_string()

static file_storage::hash_from_string (   $content)
static

Calculate and return the contenthash of the supplied content.

Parameters
string$contentThe file content
Return values
stringThe file's content hash

◆ import_external_file()

file_storage::import_external_file ( stored_file  $storedfile,
  $maxbytes = 0 
)

Convert file alias to local file.

Exceptions
moodle_exceptionif file could not be downloaded
Parameters
stored_file$storedfilea stored_file instances
int$maxbytesthrow an exception if file size is bigger than $maxbytes (0 means no limit)
Return values
stored_filestored_file

◆ is_area_empty()

file_storage::is_area_empty (   $contextid,
  $component,
  $filearea,
  $itemid = false,
  $ignoredirs = true 
)

Are there any files (or directories)

Parameters
int$contextidcontext ID
string$componentcomponent
string$fileareafile area
bool | int$itemiditem id or false if all items
bool$ignoredirswhether or not ignore directories
Return values
boolempty

◆ is_format_supported_by_unoconv()

file_storage::is_format_supported_by_unoconv (   $format)
protected

Verify the format is supported.

Parameters
string$formatThe desired format - e.g. 'pdf'. Formats are specified by file extension.
Return values
bool- True if the format is supported for input.

◆ mimetype()

static file_storage::mimetype (   $fullpath,
  $filename = null 
)
static

Return mimetype by given file pathname.

If file has a known extension, we return the mimetype based on extension. Otherwise (when possible) we try to get the mimetype from file contents.

Parameters
string$fullpathFull path to the file on disk
string$filenameCorrect file name with extension, if omitted will be taken from $path
Return values
string

◆ mimetype_from_file()

static file_storage::mimetype_from_file (   $fullpath)
static

Inspect a file on disk for it's mimetype.

Parameters
string$fullpathPath to file on disk
Return values
stringThe mimetype

◆ move_area_files_to_new_context()

file_storage::move_area_files_to_new_context (   $oldcontextid,
  $newcontextid,
  $component,
  $filearea,
  $itemid = false 
)

Move all the files in a file area from one context to another.

Parameters
int$oldcontextidthe context the files are being moved from.
int$newcontextidthe context the files are being moved to.
string$componentthe plugin that these files belong to.
string$fileareathe name of the file area.
int$itemidfile item ID
Return values
intthe number of files moved, for information.

◆ pack_reference()

static file_storage::pack_reference (   $params)
static

When user referring to a moodle file, we build the reference field.

Parameters
array$params
Return values
string

◆ search_references()

file_storage::search_references (   $reference)

Returns all aliases that refer to some stored_file via the given reference.

All repositories that provide access to a stored_file are expected to use self::pack_reference(). This method can't be used if the given reference does not use this format or if you are looking for references to an external file (for example it can't be used to search for all aliases that refer to a given Dropbox or Box.net file).

Aliases in user draft areas are excluded from the returned list.

Parameters
string$referenceidentification of the referenced file
Return values
arrayof stored_file indexed by its pathnamehash

◆ search_references_count()

file_storage::search_references_count (   $reference)

Returns the number of aliases that refer to some stored_file via the given reference.

All repositories that provide access to a stored_file are expected to use self::pack_reference(). This method can't be used if the given reference does not use this format or if you are looking for references to an external file (for example it can't be used to count aliases that refer to a given Dropbox or Box.net file).

Aliases in user draft areas are not counted.

Parameters
string$referenceidentification of the referenced file
Return values
int

◆ search_server_files()

file_storage::search_server_files (   $query,
  $from = 0,
  $limit = 20,
  $count = false 
)

Search through the server files.

The query parameter will be used in conjuction with the SQL directive LIKE, so include '' in it if you need to. This search will always ignore user files and directories. Note that the search is case insensitive.

This query can quickly become inefficient so use it sparignly.

Parameters
string$queryThe string used with SQL LIKE.
integer$fromThe offset to start the search at.
integer$limitThe maximum number of results.
boolean$countWhen true this methods returns the number of results availabe, disregarding the parameters $from and $limit.
Return values
int|arrayInteger when count, otherwise array of stored_file objects.

◆ setup_file_system()

file_storage::setup_file_system ( )

Complete setup procedure for the file_system component.

Return values
file_system

◆ sort_area_tree()

file_storage::sort_area_tree (   $tree)
protected

Sorts the result of file_storage::get_area_tree().

Parameters
array$treeArray of results provided by file_storage::get_area_tree()
Return values
arrayof sorted results

◆ supports_xsendfile()

file_storage::supports_xsendfile ( )

Returns true if filesystem is configured to support xsendfile.

Return values
bool

◆ synchronise_stored_file_from_file()

file_storage::synchronise_stored_file_from_file ( stored_file  $file,
  $path,
  $filerecord 
)

Synchronise stored file from file.

Parameters
stored_file$fileStored file to synchronise.
string$pathPath to the file to synchronise from.
stdClass$filerecordThe file record from the database.

◆ synchronise_stored_file_from_string()

file_storage::synchronise_stored_file_from_string ( stored_file  $file,
  $content,
  $filerecord 
)

Synchronise stored file from string.

Parameters
stored_file$fileStored file to synchronise.
string$contentFile content.
stdClass$filerecordThe file record from the database.

◆ test_unoconv_path()

static file_storage::test_unoconv_path ( )
static

Check if unoconv configured path is correct and working.

Return values
stdClassan object with the test status and the UNOCONVPATH_ constant message.

◆ try_content_recovery()

file_storage::try_content_recovery (   $file)

Tries to recover missing content of file from trash.

Parameters
stored_file$filestored_file instance
Return values
boolsuccess
Deprecated:
since 3.3

◆ unpack_reference()

static file_storage::unpack_reference (   $str,
  $cleanparams = false 
)
static

Unpack reference field.

Parameters
string$str
bool$cleanparamsif set to true, array elements will be passed through clean_param()
Exceptions
file_reference_exceptionif the $str does not have the expected format
Return values
array

◆ update_references()

file_storage::update_references (   $referencefileid,
  $lastsync,
  $lifetime,
  $contenthash,
  $filesize,
  $status,
  $timemodified = null 
)

Updates a reference to the external resource and all files that use it.

This function is called after synchronisation of an external file and updates the contenthash, filesize and status of all files that reference this external file as well as time last synchronised.

Parameters
int$referencefileid
int$lastsync
int$lifetimeargument not used any more, liefetime is returned by repository
string$contenthash
int$filesize
int$status0 if ok or 666 if source is missing
int$timemodifiedlast time modified of the source, if known

◆ update_references_to_storedfile()

file_storage::update_references_to_storedfile ( stored_file  $storedfile)

Updates all files that are referencing this file with the new contenthash and filesize.

Parameters
stored_file$storedfile

◆ xsendfile()

file_storage::xsendfile (   $contenthash)

Serve file content using X-Sendfile header.

Please make sure that all headers are already sent and the all access control checks passed.

Parameters
string$contenthashsah1 hash of the file content to be served
Return values
boolsuccess

The documentation for this class was generated from the following file: