You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* heavily refactored for zipstream 3.1
* docs
* create our own stream wrapper for caching output to secondary stream
* underlying package handles size estimation now, we don’t need these
* improvements for our wrapped caching output stream, with test
* comments
* more cache output options supported
* some cleanup
* Support for a callback to run after zip stream is finished
* Support for a `$zip->has($path)` check. Resolves#97
* Support adding files from Laravel Storage disks
* update docs
* update docs
* update docs
* Support saving output to disk
* update docs
* update docs
* remove this header from the streamed response
* flush output, minimize buffering and RAM usage
* add the nginx buffering header here
* getOption method in the File model
* don’t exclude any tests now
* run tests on php8.3
* s3 client requires a region
By default this package attempts to predict the final zip size and sends a `Content-Length` header up front. This means users will see accurate progress on their download, even though the zip is being streamed out as it is created!
138
+
Instead of specifying an absolute `s3://` path, you can use `addFromDisk` and specify a disk that uses the `s3` driver:
By default, this package attempts to predict the final zip size and sends a `Content-Length` header up front. This means users will see accurate progress on their download, even though the zip is being streamed out as it is created!
179
+
180
+
This only works if files are not compressed.
181
+
182
+
If you have issues with the zip size prediction you can disable it with `ZIPSTREAM_PREDICT_SIZE=false` in your .env file.
183
+
157
184
## Configure compression
158
185
159
-
By default this package uses _no_ compression. Why?
186
+
By default, this package uses _no_ compression. Why?
160
187
161
188
1) This makes building the zips super fast, and is light on your CPU
162
189
2) This makes it possible to predict the final zip size as mentioned above.
163
190
164
-
If you want to compress your zip files set `ZIPSTREAM_FILE_METHOD=deflate` in your .env file. Just realize this will disable the `Content-Length` header.
191
+
If you want to compress your zip files set `ZIPSTREAM_COMPRESSION_METHOD=deflate` in your .env file. Just realize this will disable the `Content-Length` header.
165
192
166
193
## Save Zip to disk
167
194
@@ -183,6 +210,14 @@ Zip::create("package.zip")
183
210
->saveTo("s3://bucket-name/path/to/folder");
184
211
```
185
212
213
+
Or you can save to a disk:
214
+
215
+
```php
216
+
Zip::create("package.zip")
217
+
// ... add files ...
218
+
->saveToDisk("s3", "folder");
219
+
```
220
+
186
221
## Caching zip while still streaming download
187
222
188
223
What if you have a lot of users requesting the same zip payload? It might be nice to stream out the zip while _also_ caching it to disk for the future.
You might use an internal DB id for your cache name, so that the next time a user requests a zip download you can determine if one is already built and just hand it back.
199
242
200
243
## Events
201
244
202
245
-`STS\ZipStream\Events\ZipStreaming`: Dispatched when a new zip stream begins processing
203
-
-`STS\ZipStream\Events\ZipStreamed`: Dispatched when a zip finishes streaming
204
-
-`STS\ZipStream\Events\ZipSizePredictionFailed`: Fired if the predicted filesize doesn't match the final size. If you have filesize prediction enabled it's a good idea to listen for this event and log it, since that might mean the zip download failed or was corrupt for your user.
246
+
-`STS\ZipStream\Events\ZipStreamed`: Dispatched when a zip finishes streaming
205
247
206
248
## Filename sanitization
207
249
208
-
By default this package will try to translate any non-ascii character in filename or folder's name to ascii. For example, if your filename is `中文_にほんご_Ч_Ɯ_☺_someascii.txt`. It will become `__C___someascii.txt` using Laravel's `Str::ascii($path)`.
250
+
By default, this package will try to translate any non-ascii character in filename or folder's name to ascii. For example, if your filename is `中文_にほんご_Ч_Ɯ_☺_someascii.txt`. It will become `__C___someascii.txt` using Laravel's `Str::ascii($path)`.
209
251
210
252
If you need to preserve non-ascii characters, you can disable this feature with an `.env` setting:
0 commit comments