VIDEO SAVE API 2

This commit is contained in:
Velz2020 2020-06-02 11:31:22 +05:30
parent fa66efe6c8
commit c16b2ae5d7

View File

@ -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);
}
}
}