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 =[];
if ($_SERVER["REQUEST_METHOD"] == "POST") { // if upload lets modify all the data
if ( $endpoint == 'uploads'){
log_message('critical', "ENDPOINT TESTING UPLOAD-> ".$endpoint );
$local_out=["test_msg"=>'Yes the upload endpoint was hit********'];
$call_backend = false; // will be decided after file is saved
//$fl_in=[];
$raw_json = file_get_contents('php://input');
$raw_array = json_decode($raw_json, true);
$raw_array["call_backend"] = $call_backend;
$raw_array["system_primary_uploads"] = $this->getSiteConfigurations("system.primary_uploads");
$out = ( new \App\Models\UploadManager() )->reciveUpload($raw_array, $local_out);
$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
try {
log_message('critical', "ENDPOINT TESTING UPLOAD-> ".$endpoint );
$local_out=["test_msg"=>'Yes the upload endpoint was hit********'];
$call_backend = false; // will be decided after file is saved
//$fl_in=[];
$raw_json = file_get_contents('php://input');
$raw_array = json_decode($raw_json, true);
$raw_array["call_backend"] = $call_backend;
$raw_array["system_primary_uploads"] = $this->getSiteConfigurations("system.primary_uploads");
$out = ( new \App\Models\UploadManager() )->reciveUpload($raw_array, $local_out);
$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) {
$raw_array = array_merge($_POST,$_FILES);