Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Fix S3 Service capitalization and path check
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Anarino committed Apr 22, 2018
1 parent a63eb68 commit ba7be4e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Empty file added .npmrc
Empty file.
4 changes: 4 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

version 1.0.21:
- fix capitalization of X-Amz-Security-Token for s3 uploads
- fix bucket path style check in s3 service module

version 1.0.20:
- fix path to moviemasher.js in filter definitions

Expand Down
11 changes: 5 additions & 6 deletions app/php/service/s3.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function s3_file_source($input, $config){
}
function s3_file_import_url($import, $config){
$uid = (empty($import['uid']) ? '' : $import['uid']);

return path_concat($config['user_media_protocol'] . '://' . $config['user_media_host'], path_concat($config['user_media_url'], $uid));
}
function s3_file_export_url($import, $config){
Expand All @@ -34,9 +33,9 @@ function s3_file_config_error($config = array()){
if ((! $err) && empty($config['user_media_host'])) $err = 'Configuration option user_media_host required';
if (! $err){
if (substr($config['user_media_host'], 0, strlen($config['s3_bucket'])) != $config['s3_bucket']) {
if (empty($config['user_media_directory'])) $err = 'Configuration option user_media_directory required if user_media_host does not begin with s3_bucket';
else if (substr($config['user_media_directory'], 0, strlen($config['s3_bucket'])) != $config['s3_bucket']) {
$err = 'Either user_media_host or user_media_directory must begin with s3_bucket';
if (empty($config['user_media_url'])) $err = 'Configuration option user_media_url required if user_media_host does not begin with s3_bucket';
else if (substr($config['user_media_url'], 0, strlen($config['s3_bucket'])) != $config['s3_bucket']) {
$err = 'Either user_media_host or user_media_url must begin with s3_bucket';
}
}
}
Expand All @@ -55,7 +54,7 @@ function s3_file_destination($output, $config, $prefix = 's3'){
'type' => $prefix,
'bucket' => $config[$prefix . '_bucket'],
'region' => $config[$prefix . '_region'],
'path' => path_concat(path_concat($config['user_media_url'], $output['uid']), $output['id']),
'path' => path_concat(path_concat($config['user_media_directory'], $output['uid']), $output['id']),
);
}
function s3_file_import_init($import, $config) {
Expand Down Expand Up @@ -87,7 +86,7 @@ function s3_file_import_init($import, $config) {
$formInputs = ['acl' => $config['s3_acl'], 'key' => $key];
if (! $config['aws_access_key_id']) {
$credentials = $s3->getCredentials()->wait();
$formInputs['x-amz-security-token'] = $credentials->getSecurityToken();
$formInputs['X-Amz-Security-Token'] = $credentials->getSecurityToken();
}
$conditions = [['bucket' => $config['s3_bucket']]];
$expiration = date(DATE_FORMAT_TIMESTAMP, time() + 5 * 60);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@moviemasher/angular-moviemasher",
"description": "Example deployment of moviemasher.js and moviemasher.rb utilizing AngularJS, Bootstrap and PHP",
"version": "1.0.20",
"version": "1.0.21",
"author": {
"name": "Movie Masher",
"email": "[email protected]"
Expand Down

0 comments on commit ba7be4e

Please sign in to comment.