froala / KMSFroalaEditorBundle

Symfony bundle for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
105 stars 33 forks source link

imageUploadToS3 Config #131

Open sbyshyp opened 2 months ago

sbyshyp commented 2 months ago

I can't find any clear documentation on configuring a S3 bucket for the image upload for the particular method I'm trying to use.

// kms_froala_editor.yaml
kms_froala_editor:
    serialNumber: '%env(FROALA_ACTIVATION_CODE)%'
    language: en_ca
    includeJS: true
    includeCSS: true
    htmlRemoveTags: ["base"]
    imageUploadToS3:
      bucket: '%amazon_bucket%'
      region: '%amazon_region%'
      keyStart: 'uploads/images'
      accessKeyId: '%amazon_key%'
      acl: 'public-read'

When I go to submit an image I get the following error in the browser

POST https://us-east-1.amazonaws.com/bucket net::ERR_NAME_NOT_RESOLVED

The region and bucket name conform to the aws s3 set.

I based my config on this code block:

// src/Resources/public/froala_editor/html/image_s3_upload.php
    (function(){
      new FroalaEditor("#edit",{
        enter: FroalaEditor.ENTER_P,
        fileUploadToS3: {
          bucket: '<?php echo $bucket; ?>',
          region: '<?php echo $region; ?>',
          keyStart: '<?php echo $keyStart; ?>',
          params: {
            acl: '<?php echo $acl; ?>',
            AWSAccessKeyId: '<?php echo $accessKeyId; ?>',
            policy: '<?php echo $policy; ?>',
            signature: '<?php echo $signature; ?>',
          }
        },
        events: {
          'image.uploadedToS3': function(link, key, response) {
            console.log ('S3 Link:', link)
            console.log ('S3 Key:', key)
          }
        }
      })
    })()