is there a way to force the browser to download a SimpleFile via a Controller response?
I tried the DownloadResponse, StreamResponse, FileDisplayResponse and good old DataResponse with some JavaScript โ but failed miserably. The file is stored in the AppData SimpleFileSystem. So far so good, but I would like to download it directly.
The issue is mainly that the ISimpleFile abstraction doesnโt provide all information that is needed by the Response classes to properly handle the display/download. You can work around that by fetching the file from the root folder. You can find an example over here: https://github.com/nextcloud/deck/blob/master/lib/Service/FileService.php#L211-L247
Thanks for your help! Unfortunately I only get something like this as response in the Javascript console and there is no prompt for a download. The file is a correctly created zip, I checked via ftp. Do you have another idea for that pink mess?
How do you submit the request to the download endpoint? It seems that it is a XHR request so the currently opened site gets the response data instead of the browser to handle the download.
Oh regarding the initial problem: I found that she SimpleFile Class seems to have a method โreadโ which does the fopen(โrโ) on the $file property. So this seems to work for me without the workaround:
$response = new StreamResponse($zipFile->read());
Ah indeed, I even implemented that a while ago https://github.com/nextcloud/server/pull/10122 Sorry, I was a bit confused by the fallback in the deck app then. Good to hear that it works now.