summaryrefslogtreecommitdiffstats
path: root/vendor/maennchen/zipstream-php/guides/FlySystem.rst
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2024-05-27 13:08:29 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2024-05-27 13:08:29 +0200
commit75160b12821f7f4299cce7f0b69c83c1502ae071 (patch)
tree27e25e4ccaef45f0c58b22831164050d1af1d4db /vendor/maennchen/zipstream-php/guides/FlySystem.rst
parentprvi-commit (diff)
download1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip
Diffstat (limited to 'vendor/maennchen/zipstream-php/guides/FlySystem.rst')
-rw-r--r--vendor/maennchen/zipstream-php/guides/FlySystem.rst33
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/maennchen/zipstream-php/guides/FlySystem.rst b/vendor/maennchen/zipstream-php/guides/FlySystem.rst
new file mode 100644
index 0000000..0243f24
--- /dev/null
+++ b/vendor/maennchen/zipstream-php/guides/FlySystem.rst
@@ -0,0 +1,33 @@
+Usage with FlySystem
+===============
+
+For saving or uploading the generated zip, you can use the
+`Flysystem <https://flysystem.thephpleague.com>`_ package, and its many
+adapters.
+
+For that you will need to provide another stream than the ``php://output``
+default one, and pass it to Flysystem ``putStream`` method.
+
+.. code-block:: php
+
+ // Open Stream only once for read and write since it's a memory stream and
+ // the content is lost when closing the stream / opening another one
+ $tempStream = fopen('php://memory', 'w+');
+
+ // Init Options
+ $zipStreamOptions = new Archive();
+ $zipStreamOptions->setOutputStream($tempStream);
+
+ // Create Zip Archive
+ $zipStream = new ZipStream('test.zip', $zipStreamOptions);
+ $zipStream->addFile('test.txt', 'text');
+ $zipStream->finish();
+
+ // Store File (see Flysystem documentation, and all its framework integration)
+ $adapter = new Local(__DIR__.'/path/to/folder'); // Can be any adapter (AWS, Google, Ftp, etc.)
+ $filesystem = new Filesystem($adapter);
+
+ $filesystem->putStream('test.zip', $tempStream)
+
+ // Close Stream
+ fclose($tempStream); \ No newline at end of file