Set content type when downloading log file to force download in some browsers (#25382)

This commit is contained in:
Vincent Petry 2016-07-06 22:47:16 +02:00 committed by Thomas Müller
parent dc21a38a85
commit d769e718a5
2 changed files with 4 additions and 0 deletions

View File

@ -105,6 +105,7 @@ class LogSettingsController extends Controller {
*/
public function download() {
$resp = new StreamResponse(\OC\Log\Owncloud::getLogFilePath());
$resp->addHeader('Content-Type', 'application/octet-stream');
$resp->addHeader('Content-Disposition', 'attachment; filename="owncloud.log"');
return $resp;
}

View File

@ -71,5 +71,8 @@ class LogSettingsControllerTest extends \Test\TestCase {
$response = $this->logSettingsController->download();
$this->assertInstanceOf('\OCP\AppFramework\Http\StreamResponse', $response);
$headers = $response->getHeaders();
$this->assertEquals('application/octet-stream', $headers['Content-Type']);
$this->assertEquals('attachment; filename="owncloud.log"', $headers['Content-Disposition']);
}
}