File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Garden \Web \Exception \ClientException ;
4
+ use Garden \Schema \Schema ;
5
+ use Vanilla \Utility \InstanceValidatorSchema ;
6
+ use Garden \Web \Data ;
7
+ use Garden \Web \Exception \NotFoundException ;
8
+ use Garden \Web \Exception \ServerException ;
9
+ use Vanilla \ApiUtils ;
10
+
11
+ /**
12
+ * SQL API Controller for the `/service` resource.
13
+ */
14
+ class ServiceApiController extends AbstractApiController {
15
+ /**
16
+ *
17
+ * @param array $query The query string.
18
+ * @return Data
19
+ */
20
+ public function get_tidewayslog ($ path ='/var/log/tideways/daemon.log ' ) {
21
+ $ this ->permission ('Garden.Settings.Manage ' );
22
+
23
+ if (file_exists ($ path )) {
24
+ //Get file type and set it as Content Type
25
+ $ finfo = finfo_open (FILEINFO_MIME_TYPE );
26
+ header ('Content-Type: ' . finfo_file ($ finfo , $ path ));
27
+ finfo_close ($ finfo );
28
+
29
+ header ('Content-Description: File Transfer ' );
30
+ header ('Content-Disposition: attachment; filename= ' .basename ($ path ));
31
+ header ('Expires: 0 ' );
32
+ header ('Cache-Control: must-revalidate, post-check=0, pre-check=0 ' );
33
+ header ('Pragma: public ' );
34
+ header ('Content-Length: ' . filesize ($ path ));
35
+ ob_clean ();
36
+ flush ();
37
+ readfile ($ path );
38
+ exit ;
39
+ } else {
40
+ throw notFoundException ('File ' );
41
+ }
42
+ }
43
+
44
+ }
Original file line number Diff line number Diff line change
1
+ openapi : 3.0.2
2
+ info : Vanilla Service API
3
+ paths :
4
+ /service/tidewayslog :
5
+ get :
6
+ responses :
7
+ ' 200 ' :
8
+ content :
9
+ ' text/plain ' :
10
+ schema :
11
+ type : string
12
+ description : Success
13
+ tags :
14
+ - Services
15
+ summary : File.
You can’t perform that action at this time.
0 commit comments