Coder Social home page Coder Social logo

Comments (7)

jszobody avatar jszobody commented on July 21, 2024

I can't reproduce. That code you pasted just gave me a OpI4O73yLqV92K4I5PRU.zip download file.

Is that download method in your Controller? Not sure where $this->files is coming from, but I'm not thinking this is a controller method.

Something else is getting in the way, and I would need to see the controller itself to help you further.

from laravel-zipstream.

lucdaalmeijer avatar lucdaalmeijer commented on July 21, 2024

What was the solution for this? I'm having the same issue, This is my code:

public function downloadDocumentsV2(int $year, string $type, Collection $documents = null)
{
    if (is_null($documents)) {
        $documents = $this->getDocumentsForTypeGroupWithYear($year, $type)->get();
    }

    $zip = Zip::create('package.zip');

    foreach ($documents as $document) {
        $document = $document->files->first();
        $zip->add("s3://". config('filesystems.disks.s3.bucket') . '/' . $document->path, $document->name);
    }

    return $zip;
}

@ingangelbaeza

from laravel-zipstream.

lucdaalmeijer avatar lucdaalmeijer commented on July 21, 2024

or @jszobody if you have a solution for this 🙂

from laravel-zipstream.

jszobody avatar jszobody commented on July 21, 2024

@lucdaalmeijer Is downloadDocumentsV2 a controller method? Any chance it's being returned instead from a Livewire component?

from laravel-zipstream.

lucdaalmeijer avatar lucdaalmeijer commented on July 21, 2024

yes downloadDocumentsV2 is a controller method and is being returned from an livewire component like this:

return $this->entity->downloadDocumentsV2($this->year, $this->type);

from laravel-zipstream.

jszobody avatar jszobody commented on July 21, 2024

That's your issue, you can't return a zip stream from a LiveWire component. LW wants to grab the entire response payload and serialize it inside its own JSON response, you lose all the benefits of streaming out the response (it doesn't start instantly) and LW gets in the way of the filename header.

More explanation:
#34 (comment)

Alternate approach:
#34 (comment)

from laravel-zipstream.

lucdaalmeijer avatar lucdaalmeijer commented on July 21, 2024

ohw i will look into that, thank you for the insight, response and the alternate approach!

from laravel-zipstream.

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.