From 206ec6650c706da9c030ab62bd872364604bb32f Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 5 Nov 2022 11:17:51 +0530 Subject: [PATCH] SaveshortsVDO : ps --- api/application/controllers/PD_Controller.php | 43 +++++++------------ 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 79224bf8..c4cf7b6c 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -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!';