From 794296aef88d16d3c871bd037f8775e49d9827c8 Mon Sep 17 00:00:00 2001 From: root <root@sv3.lisha.ufsc.br> Date: Mon, 20 May 2024 16:14:37 -0300 Subject: [PATCH] Fix #14 --- api/get.php | 2 -- bin/smartdata/SmartAPI.php | 9 +++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/get.php b/api/get.php index a2e39ec..3cfb236 100644 --- a/api/get.php +++ b/api/get.php @@ -58,7 +58,5 @@ if ( isset( $response['headers'] ) ){ foreach ( $response['headers'] as $header ) header( $header ); } else { - //TODO Maybe this will not be used due all queries use x-sendfile - error_log("Query not using X-SendFile!"); echo $response; } diff --git a/bin/smartdata/SmartAPI.php b/bin/smartdata/SmartAPI.php index 939fc0d..cf6c073 100644 --- a/bin/smartdata/SmartAPI.php +++ b/bin/smartdata/SmartAPI.php @@ -80,7 +80,12 @@ namespace SmartData\SmartAPI } if($return != NULL) { $pos = 0; + $isBigQuery = false; + $bigUnits = [0x02240003, 0x02230000, 0x03020000]; //Image, WAV, LIDAR foreach ( $return['series'] as $key => $sd ) { + //Check if the series are a "big unit" + $isBigQuery = in_array( $sd['unit'] & 0x0FFF0000 , $bigUnits ); + $ver = intval( $sd['version'] ); $return['series'][$pos]['version'] = ( $ver >> 4 ) . "." . ( $ver & 0x0F ); if (array_key_exists("SmartData", $sd)) { @@ -95,6 +100,7 @@ namespace SmartData\SmartAPI } // The following lines dumps the response to a file and uses X-SendFile to notify Apache to send the response. // this saves a lot of memory. + if ( $isBigQuery ) { $file_path_for_digital_series = '/smartdata/tmp/' . microtime(true) . '.gets'; file_put_contents($file_path_for_digital_series, '{"series": [' , FILE_APPEND); foreach ( $return['series'] as $key => $sd ) { @@ -107,6 +113,9 @@ namespace SmartData\SmartAPI $return['headers'][] = 'X-Sendfile: ' . $file_path_for_digital_series ; $return['headers'][] = 'Content-type: application/json' ; $return['headers'][] = 'Content-Length: ' . (filesize( $file_path_for_digital_series ) + 1) ; + } else { + $return = json_encode( $return, JSON_NUMERIC_CHECK ); + } } else { throw new RequestFailedException("Error processing request: null return"); } -- GitLab