Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function saveResourcesToS3($file_Path, $content, $type){
- $bucket = $this->aws_s3_bucket;
- $key = 'resources'.'/'.$this->application_version . $file_Path;
- $base_put_array = [
- 'Bucket' => $bucket,
- 'Key' => $key,
- 'Body' => $content,
- 'ACL' => 'public-read',
- ];
- $result = null;
- try {
- //Create a S3Client
- $s3Client = $this->S3Client;
- if(!empty($type)){
- if($type == 'css'){
- $base_put_array['ContentType'] = 'text/css';
- }
- else if($type == 'js'){
- $base_put_array['ContentType'] = 'text/javascript';
- }
- }
- if(!empty($content)){
- $result = $s3Client->putObject($base_put_array);
- }
- else{
- $result = $s3Client->putObject([
- 'Bucket' => $bucket,
- 'Key' => $key,
- 'SourceFile' => $file_Path,
- 'ACL' => 'public-read',
- ]);
- }
- // unset($content);
- // unset($base_put_array);
- // unset($result);
- // $this->garbageCollectionForce();
- } catch (Exception $e) {
- // $this->garbageCollectionForce();
- echo $e->getMessage() . "\n";
- sendMailToAll("IMPORTANT view.php saveResourcesToS3", "resources - css/js/view not getting saved to s3: " . $e->getMessage()." ");
- die();
- }
- // echo $result;
- // die();
- }
- function garbageCollectionForce(){
- gc_collect_cycles();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement