How to Integrate Amazon S3 Bucket with HD Video Share?

In this tutorial, I’ll guide you on how to integrate Amazon S3 bucket with HD Video Share for fast and secure access of video files. Amazon S3 is the storage for internet and it can be used to store and retrieve data at anytime. While using HD video share it will be useful to save your uploaded videos in Amazon server and also to display the videos from Amazon server. It increases the overall performance of your site, besides making it reliable, secure, and fast.

Here you’re with the steps to integrate the Amazon S3 bucket with HD Video Share.

Step 1: Download and save file from Amazon source

Download the S3.php file from the Amazon source and place the s3.php file on the root path of your server.

Step 2: Include S3.php file in your working site

First thing you will need to do is including the S3.php file in your current working site. You can use the php require_once() function for this purpose. This function is used to include the file only if it wasn’t included prior.

Step 3: Find the path for frontend view

Go to the path mentioned below for viewing the frontend.

Root/components/com_contushdvideoshare/models/videoupload.php

Checkout the below stated path for admin side.

Root/administrator/components/com_contushdvideoshare/models/uploadvideo.php

In these files include the s3.php in top of your file.

require_once ‘–Path of the file-/S3.php’;

 

Step 4: Access AWS using access and secret Keys

To enter the Amazon Web Services (AWS) access information the script needs to access your S3 server.

These are the Access Key and the Secret Key provided by Amazon. Kindly follow the code to place the keys.

$bucket = ‘Here your bucket name’;

$awsAccessKey = ‘Your access key’;

$awsSecretKey =’Your secret key’;

//**Important

$sourceImage = $target_paths;/* you have to define the target path

$actual_image_name = $fname . “.mp4″; /* actual video name

Step 5: Upload videos in Amazon bucket

Find the code below to upload the videos in Amazon bucket using the object.

$s3 = new S3($awsAccessKey, $awsSecretKey);

$s3->putBucket($bucket, S3::ACL_PUBLIC_READ);

if ($s3->putObjectFile($sourceImage, $bucket, $actual_image_name,                              S3::ACL_PUBLIC_READ))

{

unlink($target_paths);

}

To create a bucket we’ll use the function putBucket(bucket, acl) in which ‘bucket’ is the name that refers to Amazon’s word for your main folder or directory of files.

The second argument is the Access Control List (ACL) in which you can define who should and shouldn’t read form or write to this bucket.

Note that a bucket can be created only once. Executing the script multiple times after the first attempt won’t result in anything, since the bucket already exists.

To move the file we’ll use the function putObjectFile(source file, bucket, newfilename, acl).

The source file is the path to the file we want to move, so in your case it was the temporary file uploaded through your form. Bucket is to move the file you just created. Newfilename is the file name in bucket.

Step 6: View the uploaded files

After successful upload of your file you can view the resultant files in the URL.

http://yourbucketname.s3.amazoneaws.com/yourfile.ext

 

Step 7: Extract videos from Amazon

So far we have uploaded the videos in the Amazon bucket now we have to get the videos from the same.

Go to the file path below and replace the video URL into Amazon URL.

Root/components/com_contushdvideoshare/models/playxml.php

Find the URL Path below to pick the videos from Amazon server.

$video = ‘http://’.$bucket.’.s3.amazonaws.com/’.$rows->videourl;

Now the videos are loaded from the Amazon bucket.

By this way you could speed up the performance of your video website by storing your video files on Amazon server space and retrieving them promptly.

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" extra="">