diff --git a/flysystem_s3.js b/flysystem_s3.js index f461715..8ad510b 100644 --- a/flysystem_s3.js +++ b/flysystem_s3.js @@ -28,7 +28,7 @@ if (typeof $fileElement[0].files !== 'undefined') { // @todo This only supports the first file uploaded. var file = $fileElement[0].files[0]; - var $form = $(event.target).parents('form'); + var $form = $(event.target).closest('form'); var form_build_id = $form.find('input[name="form_build_id"]').val(); // Prevent the submit button from actually submitting. @@ -196,7 +196,7 @@ */ Drupal.behaviors.flySystemS3CorsUpload = { attach: function (context) { - $(context).find('.js-form-managed-file input[type="file"][flysystem-s3-cors]') + $(context).find('.js-form-managed-file input[type="file"][data-flysystem-s3-cors]') // Add the CORS upload handler to the file input. .once('auto-cors-upload') .on('change.autoCorsFileUpload', Drupal.flysystemS3.submitCorsUpload) @@ -205,7 +205,7 @@ }, detach: function (context, setting, trigger) { if (trigger === 'unload') { - $(context).find('.js-form-managed-file input[type="file"][flysystem-s3-cors]') + $(context).find('.js-form-managed-file input[type="file"][data-flysystem-s3-cors]') .removeOnce('auto-cors-upload') .off('change.autoCorsFileUpload', Drupal.flysystemS3.submitCorsUpload); } diff --git a/src/S3CorsManagedFileHelper.php b/src/S3CorsManagedFileHelper.php index 3c884f4..e58c7e3 100644 --- a/src/S3CorsManagedFileHelper.php +++ b/src/S3CorsManagedFileHelper.php @@ -60,7 +60,7 @@ class S3CorsManagedFileHelper { // AJAX request to sign the upload. $element['upload']['#attributes']['data-s3-acl'] = $element['#s3_acl']; $element['upload']['#attributes']['data-s3-destination'] = $element['#upload_location']; - $element['upload']['#attributes']['flysystem-s3-cors'] = TRUE; + $element['upload']['#attributes']['data-flysystem-s3-cors'] = TRUE; // Add the valid extensions as data attributes. if (!empty($element['#upload_validators']['file_validate_extensions'][0])) { @@ -116,7 +116,8 @@ class S3CorsManagedFileHelper { */ public static function getAcl($scheme) { $settings = static::getSchemeSettings($scheme); - if (isset($settings['config']['options']['ACL'])) { + + if (array_key_exists('ACL', $settings['config']['options']['ACL'])) { return $settings['config']['options']['ACL']; }