Skip to content

Instantly share code, notes, and snippets.

@BBGuy
Created November 29, 2012 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BBGuy/4167865 to your computer and use it in GitHub Desktop.
Save BBGuy/4167865 to your computer and use it in GitHub Desktop.
Drupal Amazon S3 multipart file upload
<?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
?>
@BBGuy
Copy link
Author

BBGuy commented Nov 29, 2012

call:
amazons3_upload('uploadpath/testfile.mp4', 'mytest.bucket')

@BBGuy
Copy link
Author

BBGuy commented Nov 29, 2012

requires the awssdk module http://drupal.org/project/awssdk

@BBGuy
Copy link
Author

BBGuy commented Nov 29, 2012

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