Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-69548

Add ZipStream library to core

XMLWordPrintable

    • MOODLE_310_STABLE
    • MOODLE_310_STABLE
    • MDL-69548-master
    • Hide

      Setup

      1. Add the following attached files to your Moodle root directory:
        1. MDL-69548-test.php
        2. m.png

      Testing

      1. In your web browser, visit <wwwroot>/MDL-69548-test.php.
      2. CONFIRM you receive a download prompt for a file called testing.zip.
      3. Download the testing.zip file.
      4. CONFIRM you are able to extract the zip file.
      5. CONFIRM the following files exist in the extracted zip content:
        1. hello.txt
        2. goodbye.txt
        3. some_image.png
      6. Open each of the files and CONFIRM they contain the following content:
        1. hello.txt: Text reading "This is the contents of hello.txt".
        2. goodbye.txt: Text reading "The quick brown fox jumped over the lazy dog.".
        3. some_image>png: An image of the M from the Moodle logo.
      Show
      Setup Add the following attached files to your Moodle root directory: MDL-69548 -test.php m.png Testing In your web browser, visit <wwwroot>/ MDL-69548 -test.php . CONFIRM you receive a download prompt for a file called testing.zip . Download the testing.zip file. CONFIRM you are able to extract the zip file. CONFIRM the following files exist in the extracted zip content: hello.txt goodbye.txt some_image.png Open each of the files and CONFIRM they contain the following content: hello.txt: Text reading "This is the contents of hello.txt". goodbye.txt: Text reading "The quick brown fox jumped over the lazy dog.". some_image>png: An image of the M from the Moodle logo.
    • 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;
      

        1. m.png
          m.png
          1 kB
        2. MDL-69548.jpg
          MDL-69548.jpg
          48 kB
        3. MDL-69548-test.php
          0.8 kB

            michaelh Michael Hawkins
            dobedobedoh Andrew Lyons
            Jun Pataleta Jun Pataleta
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 1 hour, 25 minutes
                1d 1h 25m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.