Comments (21)
@NicolasCARPi We should probably add a new function createDirectory
that does this. This seems like a hack to me.
I would add the function to the v1 versions only.
from zipstream-php.
Hello @dotriz,
You can do like that to create an empty directory (with version 1.0.0-alpha):
$zip->addFile('directory/', '');
from zipstream-php.
@NicolasCARPi Any plan to add this support in previous versions?
from zipstream-php.
It doesn't work in previous versions?
from zipstream-php.
@NicolasCARPi that's correct, it doesn't work on previous versions.
from zipstream-php.
I came here looking for this. I basically want to replace the PHP standard ZipArchive with this so that I can build and stream directly to s3. Our current implementation using ZipArchive uses the addEmptyDir.
I don't know if this is too ambitious, but something like a drop-in replacement for ZipArchive would be awesome. Maybe this should be a different issue.
https://www.php.net/manual/en/class.ziparchive.php
from zipstream-php.
I have faced the same issue creating empty folders fails except if using what @NicolasCARPi suggested:
$zip->addFile($directory . DIRECTORY_SEPARATOR, '');
However, testing the download of a zipStream causes unit test failure since it counts empty folders created this way as a file:
$zip = new ZipArchive();
$zip->open($tempName); // open the downloaded stream
self::assertEquals($expectedFilesCount, $zip->count); // count is incorrect -- it counts folders as file
this counts extra for each folder which is totally wrong also happens for $zip
from zipstream-php.
@maennchen Help wanted, means a pull request for it would be merged? π
from zipstream-php.
@christian-kolb a PR is very welcome π
from zipstream-php.
@maennchen I started and saw pretty quickly that I severely underestimated the complexity of this library and what is needed to make this change. The whole directory construct doesn't seem to exist in the package yet.
My approach would be to create a Directory
class according to the structure of the File
class. But I'm not sure if the concepts match here. A directory doesn't have a content but is more of a marker. I'm pretty much lost as soon as it comes to the headers and the V...
format. Can you point me to relevant documentation? Then I would try to pickup from there π
from zipstream-php.
@christian-kolb Yeah, it's not that approachable.
For every change, I also have to read the specifications.
https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
Unfortunately, I also do not know about resources that are a lot better...
from zipstream-php.
Hello, what's about this feature ?
from zipstream-php.
@bastien70 A PR would be welcome.
from zipstream-php.
I don't have the capacity to do that kind of PR sorry.
from zipstream-php.
@bastien70 And I do not have the time. If this is important to anyone, please open a PR. Otherwise there will be no solution to this anytime soon.
from zipstream-php.
@bastien70 If it is okay for your customers I would suggest a simple solution to just putting an empty file in all empty folders by default to keep the structure (kind of like how .gitignore works for git folders) and just waiting for maintainers to see what we can do. (Also check last comment of me maybe it fails on unit test but works on runtime).
from zipstream-php.
Tracked in #224
from zipstream-php.
@maennchen any new about this feature ?
from zipstream-php.
@ahmed-bhs This feature is part of the current beta release.
from zipstream-php.
Hey @maennchen 3.0.0@beta ? Does there any documentation behind the feature?
from zipstream-php.
@ahmed-bhs The docs are not published right now.
You can checkout the project and generate the docs. (composer run docs:generate)
Otherwise everything is documented in the code comments.
ZipStream-PHP/src/ZipStream.php
Line 475 in 815cf35
from zipstream-php.
Related Issues (20)
- How to add file from direct download URL ?
- How to compress output while writing contentοΌ HOT 2
- Warning from fwrite HOT 9
- TODO: Remove `PHP_CS_FIXER_IGNORE_ENV` from `composer.json`
- == Major Release 3 out for testing ==
- addFromStream
- Download is not working (downloads a file called download (without any extension))
- Add file to existing archive HOT 2
- Update Docs for Flysystem 3 HOT 4
- Document default options for Zip64 & Zero Header HOT 19
- CI no space left on device HOT 4
- Deprecate all the removed/changed code changes v2 => v3 HOT 1
- DUMB question...
- S3 steaming results in broken ZIP file HOT 4
- Update `gitattributes` file HOT 5
- Option to disable UTF-8 encoding for Content-Disposition for KOBO? HOT 6
- Unexpected end of archive - when there are more than 4 folders deep HOT 11
- Cascading subjects coming from ZIP_VERSION_MADE_BY HOT 6
- `OperationMode::SIMULATE_STRICT` and zero-byte files HOT 3
- Creating CRC fails on 32-bit system due to too small integers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zipstream-php.