fix: reset fail user fail counter on password update (#6198)
[openemr.git] / src / RestControllers / DocumentRestController.php
blob737824fab4665200bf727f6b5b6ae46327bab3da
1 <?php
3 /**
4 * DocumentRestController
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Matthew Vita <matthewvita48@gmail.com>
9 * @copyright Copyright (c) 2018 Matthew Vita <matthewvita48@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\RestControllers;
15 use OpenEMR\Services\DocumentService;
16 use OpenEMR\RestControllers\RestControllerHelper;
18 class DocumentRestController
20 private $documentService;
22 public function __construct()
24 $this->documentService = new DocumentService();
27 public function getAllAtPath($pid, $path)
29 $serviceResult = $this->documentService->getAllAtPath($pid, $path);
30 return RestControllerHelper::responseHandler($serviceResult, null, 200);
33 public function postWithPath($pid, $path, $fileData)
35 $serviceResult = $this->documentService->insertAtPath($pid, $path, $fileData);
36 return RestControllerHelper::responseHandler($serviceResult, null, 200);
39 public function downloadFile($pid, $did)
41 $results = $this->documentService->getFile($pid, $did);
43 if (!empty($results)) {
44 header('Content-Description: File Transfer');
45 header("Content-Type: " . $results['mimetype']);
46 header('Content-Disposition: attachment; filename=' . $results['filename']);
47 header('Expires: 0');
48 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
49 header('Pragma: public');
50 header('Content-Length: ' . strlen($results['file']));
51 echo $results['file'];
52 exit;
53 } else {
54 http_response_code(400);