20 Commits

Author SHA1 Message Date
Andrew Nicols
96a1a0abce MDL-77958 file: Add psr stream functionality to file API
This change introduces a new get_psr_stream() method to:
* stored_file
* file_system

This allows us to fetch a Psr Stream implementing the
PSR\Http\Message\StreamInterface and pass it into Guzzle, which means
that there is no need to load the entire file content into memory to
serve it.
2023-04-19 13:51:49 +08:00
Brendan Heywood
fe88783c0f MDL-70368 files: Cache image dimensions 2022-09-19 13:21:20 +10:00
Huong Nguyen
816aa7aec2 MDL-55243 files: Make is_valid_image support SVG files 2021-06-24 09:02:05 +07:00
Marina Glancy
a7553de7ad MDL-70877 php: remove final functions __clone and __wakeup
Implementing these functions as final does not prevent the object to be
cloned or serialized, so the comment to them was wrong.
However having these functions not public breaks in PHP 8.0.
It still does not make sense to clone or serialise file_system or external_settings classes
but there are a lot of classes in moodle that should not be cloned, no reason to have
a specific solution here.
2021-02-26 13:07:52 +01:00
Brendan Heywood
5bf5a7aaeb MDL-68342 files: Add a faster xsendfile method to avoid db lookups 2020-04-27 16:11:34 +10:00
Andrew Nicols
9d0192e9ce Merge branch 'MDL-58281-file-missing-500' of https://github.com/brendanheywood/moodle 2020-01-07 11:30:30 +08:00
Eloy Lafuente (stronk7)
4621917c62 MDL-67114 core: php74 fix. Fix use of scalar as array in core
There are various places where it's not guaranteed that the
variable being used is array, and instead, can be null, bool, int...

We need to check that because php74 warns about it.

Where possible we have used the coalesce operator as
replacement for isset() ternary operations.
2020-01-03 11:33:15 +01:00
Brendan Heywood
1fef1de592 MDL-58281 files: Correctly handle missing files in readfile_accel 2019-12-30 17:18:49 +11:00
Mikhail Golenkov
1a15925240 MDL-66304 files: Allow xsendfile support in alternative file system. 2019-09-30 09:00:57 +10:00
Mark Nelson
94c71056a3 MDL-35773 core_backup: use existing API to recover files 2019-07-26 11:59:56 +08:00
Mark Nelson
88031d35de MDL-35773 core: revert introduction of new recover_file() method
Also -

1. Reverted recover_file() in file_system_filedir back to its
   original state.
2. Removed no longer needed method create_recovery_record().
2019-07-26 11:59:56 +08:00
Matt Porritt
d7e4481e98 MDL-35773 Backup: API should have option to not backup files
Allow both UI and automated backups to be created without
including files.  Instead include only file references.
This is essentially implementing "SAMESITE" to backup files
instead of only for import and export functionality.
A new backup setting to include files (defaults to yes)
has been included.

The restore process will also look for and attempt to
restore files from the trashdir as part of restoring
backups.  Additionally to support this process the
ammount of time files are kept in trashdir before they
are cleaned up via cron is also adjustable via admin
setting.
2019-07-26 11:59:56 +08:00
Damyon Wiese
022dccf2a7 Merge branch 'MDL-60001_gzopen' of https://github.com/mrmark/moodle 2017-10-19 13:00:13 +08:00
Matt Clarkson
b1eb6dd7f2 MDL-33174 lib/filestorage: Add filename to curl request
While the lack of the filename in curl POST does not
directly affect Moodle, some external API's expect to get
the filename of the original file, which affects plugins
using the CURL class.
2017-10-02 09:27:51 +13:00
Dan Poltawski
a1b8b9c9b5 Merge branch 'MDL-59960_mimetype' of https://github.com/mrmark/moodle 2017-09-19 09:10:24 +01:00
Mark Nielsen
879827d6fa MDL-60001 core_files: Use local file for gzopen
The gzopen method does not appear to support
file streams.
2017-08-31 15:47:00 -07:00
Mark Nielsen
ee8bce2d3b MDL-59960 core_files: improve mimetype detection
Improve mimetype detection for remote files that
have no file extension.  The mimetype detection
that makes use of the file, only works with local
files, so do not use the remote path which can be
a URL or stream.
2017-08-28 11:36:15 -07:00
Mark Nielsen
9eb1a2c31a MDL-59961 core_files: make content hash validation reusable
Other file systems could make use of this code as they
all need to validate the content has and be able to read
the file from disk.
2017-08-28 11:15:12 -07:00
Andrew Nicols
a30a04fa01 MDL-58297 filestorage: New functions for hash calculation 2017-04-07 10:40:23 +08:00
Andrew Nicols
16a34ae189 MDL-46375 core_files: Split parts of file_storage into new file system
This change moves all operations which deal with the fetching/updating, or
setting of files from the file_storage class into a new file_system class.

A new file_system can be specified in the config.php and used to replace
all relevant methods in order to move the file system component to an
alternative solution.
2017-02-14 08:42:28 +08:00