After much Googling and back-and-forth both in the GitHub repository and in the Amazon documentation for the new PHP SDK, Ive got a solution using the new Amazon SDK for creating form fields and Uploadify to actually upload the file directly to Amazon, bypassing mine server. The code looks something like this:
<?php $bucket = (string) $container['config']->images->amazon->bucket; $options = array( 'acl' => CannedAcl::PUBLIC_READ, 'Content-Type' => 'audio/mpeg', 'key' => 'audio/a-test-podcast.mp3', 'success_action_redirect' => (string) $container['config']->main->base_url . 'upload/success/', 'success_action_status' => 201, 'filename' => '^' ); $postObject = new PostObject($container['amazon_s3'], $bucket, $options); $postObject->prepareData(); $formAttributes = $postObject->getFormAttributes(); $formInputs = $postObject->getFormInputs(); $uploadPath = $formAttributes['action']; ?> <script> (function($) { $('#podcast').uploadify({ 'buttonClass': 'button', 'buttonText': 'Upload', 'formData': <?php echo json_encode($formInputs); ?>, 'fileObjName': 'file', 'fileTypeExts': '*.mp3', 'height': 36, 'multi': false, 'onUploadError': function(file, errorCode, errorMsg, errorString) { console.log('onUploadError', file, errorCode, errorMsg, errorString); }, 'onUploadSuccess': function(file, data, response) { console.log('onUploadSuccess', file, data, response); }, 'swf': '/assets/cms/swf/uploadify.swf', 'uploader': '<?php echo $uploadPath; ?>', 'width': 120 }); })(jQuery); </script>
source share