0

On my Symfony 2.7 website I created a custom Bundle to make a simple API. I don't use any vendors and all the codes are developed from scratch (it's a small REST API, for a very limited and private scope of users/friends).

In my controller I send Json responses if some of the functions and tests failed :

if ( !all_is_ok() )
{
    return new JsonResponse(" [...] JSON array with error details [...] ");
}
else
{
    // Force download of a specific file
}

How to force download in the "else" statement of the code above ? Do i have to use the Response component ?

P.S : the client of this API is a PHP script with a curl() call. How to manage file download in such specific case ? Do I have to output the URL link in JSON ?

in fact I've already tested BinaryFileResponse but result is not what I expected. If I make a CURL call with the POST method (CURLOPT_POST = 1), result is : Error: "" - Code: 0

Thanks for your help !

Paolito75
  • 558
  • 1
  • 11
  • 33
  • 1
    Check out: https://stackoverflow.com/questions/39603052/symfony-download-files – Tokeeen.com Nov 30 '17 at 11:22
  • @Tokeeen.com, in fact I've already tested BinaryFileResponse but result is not what I expected. If trying to make a CURL call with the POST method (CURLOPT_POST = 1), result is : Error: "" - Code: 0 – Paolito75 Nov 30 '17 at 14:02

0 Answers0