Aerror management on uploads

This commit is contained in:
CHIEFSOFT\ameye
2023-12-16 07:29:15 -05:00
parent 7d07ecb91d
commit 112d24e2b2
+19 -12
View File
@@ -546,18 +546,25 @@ class WrenchApi extends BaseController
$local_out =[]; $local_out =[];
if ($_SERVER["REQUEST_METHOD"] == "POST") { // if upload lets modify all the data if ($_SERVER["REQUEST_METHOD"] == "POST") { // if upload lets modify all the data
if ( $endpoint == 'uploads'){ if ( $endpoint == 'uploads'){
log_message('critical', "ENDPOINT TESTING UPLOAD-> ".$endpoint );
$local_out=["test_msg"=>'Yes the upload endpoint was hit********']; try {
$call_backend = false; // will be decided after file is saved log_message('critical', "ENDPOINT TESTING UPLOAD-> ".$endpoint );
//$fl_in=[]; $local_out=["test_msg"=>'Yes the upload endpoint was hit********'];
$raw_json = file_get_contents('php://input'); $call_backend = false; // will be decided after file is saved
$raw_array = json_decode($raw_json, true); //$fl_in=[];
$raw_array["call_backend"] = $call_backend; $raw_json = file_get_contents('php://input');
$raw_array["system_primary_uploads"] = $this->getSiteConfigurations("system.primary_uploads"); $raw_array = json_decode($raw_json, true);
$out = ( new \App\Models\UploadManager() )->reciveUpload($raw_array, $local_out); $raw_array["call_backend"] = $call_backend;
$call_backend = $out["call_backend"]; $raw_array["system_primary_uploads"] = $this->getSiteConfigurations("system.primary_uploads");
$in["message"] = $raw_array["message"] = $out["message"]; $out = ( new \App\Models\UploadManager() )->reciveUpload($raw_array, $local_out);
$raw_array["file_data"] = $out['file_data'] = $in['file_data'] =""; // no need to carry raw file data anymore - saved or cached ath this point $call_backend = $out["call_backend"];
$in["message"] = $raw_array["message"] = $out["message"];
$raw_array["file_data"] = $out['file_data'] = $in['file_data'] =""; // no need to carry raw file data anymore - saved or cached ath this point
} catch (Exception $e) {
$error = 'Caught exception: '. $e->getMessage();
log_message('critical', "ERROR ENDPOINT TESTING UPLOAD-> ".$error );
}
} }
if (isset($_FILES) && is_array($_FILES) && count($_FILES)>0) { if (isset($_FILES) && is_array($_FILES) && count($_FILES)>0) {
$raw_array = array_merge($_POST,$_FILES); $raw_array = array_merge($_POST,$_FILES);