Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download Response Not working #1331

Closed
Iamscalla opened this issue Oct 19, 2018 · 4 comments
Closed

Download Response Not working #1331

Iamscalla opened this issue Oct 19, 2018 · 4 comments

Comments

@Iamscalla
Copy link
Contributor

Iamscalla commented Oct 19, 2018

The download response isn't working as expected, when the download is initiated, the page goes blank.
the response is expected to return the send method, but does not.

here is how i used the response

$fname = $storepath.$order->order_reference . "_ticket.pdf";
Services::response()->download($fname, NULL);

so i altered the download method to return return $response->send(); instead of return $response;

i initially thought the send would be returned from the codeigniter class.

@vince83110
Copy link

Why don't use this :

Services::response()->download($fname, NULL)->send();

It's logical for me to use special method to send the result. Since you can use several methods on the DownloadResponse.

@ytetsuro
Copy link
Contributor

Have you returned the DownloadResponse class?
Please implement as follows.

<?php namespace App\Controllers;

use CodeIgniter\Controller;
use CodeIgniter\Config\Services;

class Sample extends Controller
{
    public function donwload()
    {
        $fname = __FILE__;
        return Services::response()->download($fname, NULL);
    }
}

@Iamscalla
Copy link
Contributor Author

Iamscalla commented Oct 22, 2018

@ytetsuro you make a point. But then a simple download helper would be nice. And an update to the doc

@lonnieezell
Copy link
Member

Yes, the response must be returned. This gives it a chance to run through any filters before being sent.

I'll double check the docs on that and make sure they reflect the current process since the recent change.

lonnieezell added a commit that referenced this issue Oct 24, 2018
Update docs for downloads to reflect the need to return it. Fixes #1331
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants