SaveshortsVDO : ps

This commit is contained in:
VE10-Sanjeev 2022-11-05 11:17:51 +05:30
parent 78f19dfc5e
commit 206ec6650c

View File

@ -9037,44 +9037,31 @@ class PD_Controller extends REST_Controller
$config = array('upload_path' => $folder_to_check, 'overwrite' => TRUE, 'allowed_types' => '*', 'file_name' => $file_name_wo_extension . '.' . $file_type);
$this->load->library('upload', $config);
if ($this->upload->do_upload('video_file')) {
$upload_data = $this->upload->data();
$command_to_execute = FFMPEG_PATH . ' -i ' . $folder_to_check . '/' . $file_name_wo_extension . '.' . $file_type . ' ' . $folder_to_check . '/' . $file_name_wo_extension . '.mp4' . ' 2>&1';
exec($command_to_execute, $o, $v);
if ($o) {
$sourcefile = $folder_to_check . '/' . $file_name_wo_extension . '.mp4';
$bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile);
$s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data);
// print_r($s3result);
if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) {
$uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, $time = '+1 week');
log_message('ERROR', '###PD SHORTS VIDEO stored in S3 uri = ' . $uri);
unlink($folder_to_check . '/' . $file_name_wo_extension . '.webm');
unlink($folder_to_check . '/' . $file_name_wo_extension . '.mp4');
$record_data = array('fk_pd_id' => $pd_id, 'pd_document_title' => 'Video', 'pd_document_name' => $temp_file_name, 'fk_form_id' => $form_id, 'is_show_report' => 1, 'rental_count_id' => null, 'location' => null, 'co_applicant_id' => null, 'img_type' => null, 'image_key' => "video", "pd_image_alias_name" => null,"content_type"=>2);
$record_data['company_id'] = null;
$id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS);
if ($id != null || $id != "") {
$pks['id'] = $id;
$pks['uri'] = $uri;
}
}
$sourcefile = $folder_to_check . '/' . $file_name_wo_extension . '.mp4';
$bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile);
$s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data);
if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) {
$uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, $time = '+1 week');
log_message('ERROR', '###PD SHORTS VIDEO stored in S3 uri = ' . $uri);
$record_data = array('fk_pd_id' => $pd_id, 'pd_document_title' => 'Video', 'pd_document_name' => $temp_file_name, 'fk_form_id' => $form_id, 'is_show_report' => 1, 'rental_count_id' => null, 'location' => null, 'co_applicant_id' => null, 'img_type' => null, 'image_key' => "video", "pd_image_alias_name" => null,"content_type"=>2);
$record_data['company_id'] = null;
$id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS);
if($folder_to_check . '/' . $file_name_wo_extension . '.webm'){unlink($folder_to_check . '/' . $file_name_wo_extension . '.webm');}
if($folder_to_check . '/' . $file_name_wo_extension . '.mp4'){unlink($folder_to_check . '/' . $file_name_wo_extension . '.mp4');}
if ($id != null || $id != "") {
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['msg'] = 'Video Saved Successfully';
$data['records'] = $pks;
$data['records'] = array('id'=>$id,'uri'=>$uri);
$this->response($data, REST_Controller::HTTP_OK);
} else {
}
else{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
$data['msg'] = 'Something Wrong. Try Later!';
$this->response($data, REST_Controller::HTTP_OK);
}
} else {
}else{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
$data['msg'] = 'Something Wrong. Try Later!';