Created
November 29, 2012 09:46
-
-
Save BBGuy/4167865 to your computer and use it in GitHub Desktop.
Drupal Amazon S3 multipart file upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function amazons3_upload($file, bucket) | |
if(!libraries_load('awssdk')) { | |
print t('Unable to load the AWS SDK. Please check you have installed the library correctly and configured your S3 credentials.</br>'); | |
return; | |
} | |
else if(!class_exists('AmazonS3')) { | |
print t('Cannot load AmazonS3 class. Please check the awssdk is installed correctly.</br>'); | |
return; | |
} | |
$s3 = new AmazonS3(); | |
$filename = basename($file); | |
$opt = array( | |
'fileUpload' => $file, | |
'acl' => AmazonS3::ACL_PRIVATE, | |
'storage' => AmazonS3::STORAGE_STANDARD, | |
); | |
$response = $s3->create_mpu_object($bucket, $filename, $opt); | |
return $response | |
?> |
requires the awssdk module http://drupal.org/project/awssdk
requires the Amazons3 module http://drupal.org/project/amazons3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
call:
amazons3_upload('uploadpath/testfile.mp4', 'mytest.bucket')