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

Add ZipStream library to core

    XMLWordPrintable

    Details

    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_310_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE
    • Pull 3.10 Branch:
      MDL-69548-310
    • Pull Master Branch:
      MDL-69548-master
    • Story Points:
      0
    • Sprint:
      International 4.0 - Sprint 5, International 4.0 - Sprint 6, International 4.0 - Sprint 7

      Description

      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;
      

        Attachments

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

          Issue Links

            Activity

              People

              Assignee:
              michaelh Michael Hawkins
              Reporter:
              dobedobedoh Andrew Nicols
              Peer reviewer:
              Jun Pataleta
              Integrator:
              Sara Arjona (@sarjona)
              Tester:
              Anna Carissa Sadia
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Nov/20

                  Time Tracking

                  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