diff --git a/api/application/config/routes.php b/api/application/config/routes.php index f8cca19c..43e88e11 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -411,4 +411,6 @@ $route['smcPhotoPDFDownload'] = 'SMC_Credit_PD_Controller/imgPDFDownload'; $route['myFunction']='Flyhi_Controller/myFunction'; $route['previewDigiLockerDocs']='Flyhi_Controller/previewDigiLockerDocs'; -$route['purge_pddata']='Data_Dump_Controller/renamingExistingPDinfo'; \ No newline at end of file +$route['purge_pddata']='Data_Dump_Controller/renamingExistingPDinfo'; +$route['checkjsonPD']='Data_Dump_Controller/checkjsonPD'; +$route['deleteS3Image']='Data_Dump_Controller/deleteS3Images'; \ No newline at end of file diff --git a/api/application/controllers/Data_Dump_Controller.php b/api/application/controllers/Data_Dump_Controller.php index dad17101..c4861c54 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -959,22 +959,8 @@ class Data_Dump_Controller extends REST_Controller // Delete the given file unlink($file); } - $bucketname = LENDER_BUCKET_NAME_PREFIX . $pdlenid; - $key = 'pd' . $pdid; - $s3result = $this->aws_s3->deleteSingleObjFromBucket($bucketname, $key); - if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - log_message('ERROR', "s3result " . $s3result['@metadata']['statusCode']); - } else { - log_message('ERROR', "Check here Not updated on S3 result " . $s3result['@metadata']['statusCode']); - } - $bucket_name = OPTIMIZED_IMAGE_BUCKET_NAME; - $optimizeds3result = $this->aws_s3->deleteSingleObjFromBucket($bucket_name, $key); - if (is_object($optimizeds3result) && $optimizeds3result['ObjectURL'] != '' && $optimizeds3result['@metadata']['statusCode'] == 200) { - log_message('ERROR', "optimizeds3result " . $optimizeds3result['@metadata']['statusCode']); - } else { - log_message('ERROR', "Check here Not updated on Optimized s3 result " . $optimizeds3result['@metadata']['statusCode']); - } } + $this->deleteS3Images($pdlenid,$pdid); } $updt_on_tgr['pd_status'] = ARCHIVED; $updt_tgr_where = array('pd_id' => $pdid, 'pd_status' => QC_COMPLETED); @@ -1040,8 +1026,41 @@ class Data_Dump_Controller extends REST_Controller $data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); $dat['j'] = (json_decode($data[0]['json'],true)); $dat['pj'] =(json_decode($data[0]['processed_json'],true)); - $this->response($dat, REST_Controller::HTTP_OK); - - + $this->response($dat, REST_Controller::HTTP_OK); } + + public function deleteS3Images($pdLenId,$pdid){ + // public function deleteS3Images_get(){ + // $pdid = $this->get('pdid');$rs = $this->get('rs'); + // $master = $this->PD_Model->getPDMasterDetails($pdid,$rs); + // $pdLenId = $master[0]['fk_lender_id']; + $bucketName = LENDER_BUCKET_NAME_PREFIX . $pdLenId; + $key = 'pd' . $pdid; + $allFiles = $this->aws_s3->getAllObjectsInaBucket($bucketName, $key); + if(!empty($allFiles)){ + foreach ($allFiles as $files) { + log_message('ERROR', "Lender File Name " . $files['Key']); + $s3result = $this->aws_s3->deleteSingleObjFromBucket($bucketName, $files['Key']); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + log_message('ERROR', "s3result " . $s3result['@metadata']['statusCode']); + } else { + log_message('ERROR', "Check here Not updated on S3 result " . $s3result['@metadata']['statusCode']); + } + } + } + $allOptimizedFiles = $this->aws_s3->getAllObjectsInaBucket(OPTIMIZED_IMAGE_BUCKET_NAME, $key); + if(!empty($allOptimizedFiles)){ + // print_r($allOptimizedFiles); + foreach ($allOptimizedFiles as $files) { + log_message('ERROR', "Optimized File Name " . $files['Key']); + $optimizeds3result = $this->aws_s3->deleteSingleObjFromBucket(OPTIMIZED_IMAGE_BUCKET_NAME, $files['Key']); + if (is_object($optimizeds3result) && $optimizeds3result['ObjectURL'] != '' && $optimizeds3result['@metadata']['statusCode'] == 200) { + log_message('ERROR', "optimizeds3result " . $optimizeds3result['@metadata']['statusCode']); + } else { + log_message('ERROR', "Check here Not updated on Optimized s3 result " . $optimizeds3result['@metadata']['statusCode']); + } + } + } + } + }