Upload engine

This commit is contained in:
CHIEFSOFT\ameye
2023-06-03 16:42:11 -04:00
parent 871c42bb4a
commit 2552160a71
7 changed files with 22 additions and 16 deletions
+3 -1
View File
@@ -33,4 +33,6 @@ defined('CI_DEBUG') || define('CI_DEBUG', true);
define('ENV_ID', 'DEVLP20233103-A3'); define('ENV_ID', 'DEVLP20233103-A3');
define('HOME_PAGE_BACKGROUND', 'api_bk.jpg'); define('HOME_PAGE_BACKGROUND', 'api_bk.jpg');
define('CACHE_DOMAIN', 'wrench.dev'); define('CACHE_DOMAIN', 'wrench.dev');
define('WRENCHBOARD_UPLOAD_PATH', '/opt/wrenchboard/TEST/');
+3 -1
View File
@@ -22,4 +22,6 @@ defined('CI_DEBUG') || define('CI_DEBUG', false);
define('ENV_ID', 'PRAODUCTIONG20233103-A3'); define('ENV_ID', 'PRAODUCTIONG20233103-A3');
define('HOME_PAGE_BACKGROUND', 'api_bk.jpg'); define('HOME_PAGE_BACKGROUND', 'api_bk.jpg');
define('CACHE_DOMAIN', 'wrench.prod'); define('CACHE_DOMAIN', 'wrench.prod');
define('WRENCHBOARD_UPLOAD_PATH', '/opt/wrenchboard/LIVE/');
+3 -1
View File
@@ -33,4 +33,6 @@ defined('CI_DEBUG') || define('CI_DEBUG', true);
define('ENV_ID', 'TESTING20233103-A3'); define('ENV_ID', 'TESTING20233103-A3');
define('HOME_PAGE_BACKGROUND', 'api_bk.jpg'); define('HOME_PAGE_BACKGROUND', 'api_bk.jpg');
define('CACHE_DOMAIN', 'wrench.test'); define('CACHE_DOMAIN', 'wrench.test');
define('WRENCHBOARD_UPLOAD_PATH', '/opt/wrenchboard/TEST/');
+3 -3
View File
@@ -473,9 +473,9 @@ class WrenchApi extends BaseController
$raw_json = file_get_contents('php://input'); $raw_json = file_get_contents('php://input');
$raw_array = json_decode($raw_json, true); $raw_array = json_decode($raw_json, true);
$raw_array["call_backend"] = $call_backend; $raw_array["call_backend"] = $call_backend;
$ll = ( new \App\Models\UploadManager() )->reciveUpload($raw_array, $local_out); $out = ( new \App\Models\UploadManager() )->reciveUpload($raw_array, $local_out);
$call_backend = $local_out["call_backend"]; $call_backend = $out["call_backend"];
$raw_array["message"] = $local_out["message"]; $raw_array["message"] = $out["message"];
} }
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);
+2 -3
View File
@@ -5,8 +5,7 @@ use CodeIgniter\Model;
class UploadManager extends Model class UploadManager extends Model
{ {
public $savePath = WRENCHBOARD_UPLOAD_PATH; //"/opt/wrenchboard/TEST/";
public $savePath ="/opt/wrenchboard/TEST/";
public function reciveUpload($in,$out){ public function reciveUpload($in,$out){
$action = $in["action"]; $action = $in["action"];
@@ -53,7 +52,7 @@ class UploadManager extends Model
} }
return 0; return $out;
} }
+4 -3
View File
@@ -1,8 +1,8 @@
<?php <?php
function reciveUpload($in,$out){ function reciveUpload($in, $out){
$savePath ="/opt/wrenchboard/TEST/"; $savePath = WRENCHBOARD_UPLOAD_PATH; //"/opt/wrenchboard/TEST/";
$action = $in["action"]; $action = $in["action"];
@@ -46,6 +46,7 @@ function reciveUpload($in,$out){
case WRENCHBOARD_CONTRACT_MESSAGE: case WRENCHBOARD_CONTRACT_MESSAGE:
// MAKE SURE FOLDER AS PER PROECESS IS AVILABLE // MAKE SURE FOLDER AS PER PROECESS IS AVILABLE
$out["call_backend"] = false; // flag ready to save data entry
$thisContactFolder = $savePath.'CONTRACTS/'.$in["contract"]; $thisContactFolder = $savePath.'CONTRACTS/'.$in["contract"];
if (!file_exists($thisContactFolder)) { if (!file_exists($thisContactFolder)) {
mkdir($thisContactFolder, 0777, true); mkdir($thisContactFolder, 0777, true);
@@ -66,7 +67,7 @@ function reciveUpload($in,$out){
} }
return 0; return $out;
} }
+4 -4
View File
@@ -137,13 +137,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ( $endpoint == 'uploads'){ if ( $endpoint == 'uploads'){
$local_out=["test_msg"=>'Yes the upload endpoint was hit******** 777']; $local_out=["test_msg"=>'Yes the upload endpoint was hit******** 777'];
$call_backend = false; // will be decided after file is saved $call_backend = false; // will be decided after file is saved
//$out=[];
$in = flatten(json_decode(file_get_contents('php://input'), true)); $in = flatten(json_decode(file_get_contents('php://input'), true));
//$in = json_decode($raw_json, true); //$in = json_decode($raw_json, true);
$in["call_backend"] = $call_backend; $in["call_backend"] = $call_backend;
$ll = reciveUpload($in, $local_out); $out = reciveUpload($in, $local_out);
$call_backend = $local_out["call_backend"]; $call_backend = $out["call_backend"];
$in["message"] = $local_out["message"]; $in["message"] = $out["message"];
} }
else{ else{