-
New Feature
-
Resolution: Fixed
-
Minor
-
3.10
-
MOODLE_310_STABLE
-
MOODLE_310_STABLE
-
MDL-69548-master -
-
0
-
International 4.0 - Sprint 5, International 4.0 - Sprint 6, International 4.0 - Sprint 7
Look to add the ZipStream library to core: https://github.com/maennchen/ZipStream-PHP
Without using composer
Will need a new wrapper in core\zipstream to extend ZipStream\ZipStream and definition in lib/classes/component.php
Wrapper should have a Moodle abstraction to get an instance with a default configuration suitable for most cases, like:
$writer = \core\zipstream::get_stream_writer($filename, $options);
|
// OR
|
$writer = \core\zipstream::get_file_writer($filename, $filepath, $options);
|
Note: For the get_file_writer option it is possible to pass a stream resource (i.e. one opened by fopen). See https://github.com/maennchen/ZipStream-PHP/wiki/Available-options for information - it's the setOutputStream($fd) option.
Our own \core\zipstream should also offer functions:
public function add_file_from_stored_file(string $name, stored_file $file, ?FileOptions $options = null): void;
|
public function add_file_from_string(string $name, string $filecontent, ?FileOptions $options = null): void;
|
public function add_file_from_path(string $name, string $path, ?FileOptions $options = null): void;
|