diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 3850b980..cd3bd412 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -9251,27 +9251,31 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() public function saveCusVideo_post() { - $records = $this->post('records'); + $records = json_decode($this->post('records'),true); + //$this->post('records'); $id = null; - $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']); - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - $key = 'pd'.$records['pd_id'].'/video/'.$records['filename']; - - - //$temp_file = XLPATH.'/pd_reports/'.$records['pd_id'].'/temp.txt'; - $sourcefile = $_FILES['video_file']['tmp_name']; - // $current_file = fopen($temp_file,'w'); - // fwrite($current_file, $records['video_blob']); - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$temp_file); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - log_message('ERROR','###PDVIDEO stored in S3'.$records['pd_id']); - $record_data = array('fk_pd_id' => $records['pd_id'],'video_part_name'=>$records['filename']); - $id = $this->PD_Model->saveRecords($record_data,CUS_VIDEO); - - } + log_message('ERROR',print_r($records)); + if(!empty($_FILES['video_file'])) + { + $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']); + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; + $key = 'pd'.$records['pd_id'].'/video/'.$records['filename']; + //print_r($pd_master_details);//die(); + + //$temp_file = XLPATH.'/pd_reports/'.$records['pd_id'].'/temp.txt'; + $sourcefile = $_FILES['video_file']['tmp_name']; + // $current_file = fopen($temp_file,'w'); + // fwrite($current_file, $records['video_blob']); + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$temp_file); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + print_r($s3result); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + log_message('ERROR','###PDVIDEO stored in S3'.$records['pd_id']); + $record_data = array('fk_pd_id' => $records['pd_id'],'video_part_name'=>$records['filename']); + $id = $this->PD_Model->saveRecords($record_data,CUS_VIDEO); + + } if($id != null || $id != "") { @@ -9288,6 +9292,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $this->response($data,REST_Controller::HTTP_OK); } + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'No Image found to upload'; + $this->response($data,REST_Controller::HTTP_OK); + } } }