Code Monkey home page Code Monkey logo

Comments (21)

maennchen avatar maennchen commented on May 20, 2024 4

@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.

NicolasCARPi avatar NicolasCARPi commented on May 20, 2024 2

Hello @dotriz,

You can do like that to create an empty directory (with version 1.0.0-alpha):

$zip->addFile('directory/', '');

from zipstream-php.

dotriz avatar dotriz commented on May 20, 2024

@NicolasCARPi Any plan to add this support in previous versions?

from zipstream-php.

NicolasCARPi avatar NicolasCARPi commented on May 20, 2024

It doesn't work in previous versions?

from zipstream-php.

dotriz avatar dotriz commented on May 20, 2024

@NicolasCARPi that's correct, it doesn't work on previous versions.

from zipstream-php.

claytron5000 avatar claytron5000 commented on May 20, 2024

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.

walkingCommiter avatar walkingCommiter commented on May 20, 2024

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.

christian-kolb avatar christian-kolb commented on May 20, 2024

@maennchen Help wanted, means a pull request for it would be merged? πŸ™‚

from zipstream-php.

maennchen avatar maennchen commented on May 20, 2024

@christian-kolb a PR is very welcome πŸ™‚

from zipstream-php.

christian-kolb avatar christian-kolb commented on May 20, 2024

@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.

maennchen avatar maennchen commented on May 20, 2024

@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.

bastien70 avatar bastien70 commented on May 20, 2024

Hello, what's about this feature ?

from zipstream-php.

maennchen avatar maennchen commented on May 20, 2024

@bastien70 A PR would be welcome.

from zipstream-php.

bastien70 avatar bastien70 commented on May 20, 2024

I don't have the capacity to do that kind of PR sorry.

from zipstream-php.

maennchen avatar maennchen commented on May 20, 2024

@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.

walkingCommiter avatar walkingCommiter commented on May 20, 2024

@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.

maennchen avatar maennchen commented on May 20, 2024

Tracked in #224

from zipstream-php.

ahmed-bhs avatar ahmed-bhs commented on May 20, 2024

@maennchen any new about this feature ?

from zipstream-php.

maennchen avatar maennchen commented on May 20, 2024

@ahmed-bhs This feature is part of the current beta release.

from zipstream-php.

ahmed-bhs avatar ahmed-bhs commented on May 20, 2024

Hey @maennchen 3.0.0@beta ? Does there any documentation behind the feature?

from zipstream-php.

maennchen avatar maennchen commented on May 20, 2024

@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.

from zipstream-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.