froala / wysiwyg-editor

The next generation Javascript WYSIWYG HTML Editor.
https://www.froala.com/wysiwyg-editor
Other
5.28k stars 672 forks source link

Parsing response failed uploading image to s3 bucket #3843

Open cbielich opened 4 years ago

cbielich commented 4 years ago

No matter what I do I get this error.

Parsing response failed

PHP

require 'wysiwyg-editor-php-sdk-master/lib/FroalaEditor.php';
// Configuration object.
$config = array(
  // Your server timezone.
  'timezone' => 'America/Los_Angeles',

  // The name of your bucket.
  'bucket' => 'bucketname',

  // S3 region. If you are using the default us-east-1, it this can be ignored.
  // Read more on: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region.
  'region' => 'us-west-2',

  // The folder where to upload the files.
  'keyStart' => 'folder',

  // File access.
  'acl' => 'public-read',

  // AWS keys.
  'accessKey' => '**********************',
  'secretKey' => '******************************************************************'
);
// Compute the signature.

$s3Hash = FroalaEditor_S3::getHash($config);
$s3Hash = json_encode($s3Hash);

Froala

$(function() {
    $('.comment').froalaEditor({
        toolbarButtons: ['insertImage', 'insertFile','insertLink', 'formatBlock', 'fontSize', 'color', 'bold', 'italic', 'underline', 'strikeThrough', 'outdent', 'indent', 'align', 'formatOL', 'formatUL', 'clearFormatting'],
        key: '*************************************************',
        imageUploadToS3: JSON.parse('<?=$s3Hash?>'),
        fileUploadToS3: JSON.parse('<?=$s3Hash?>'),
        imageUploadURL: false,          
    })
    })

CORS

<?xml version="1.0" encoding="UTF-8"?>
    <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>https://www.example.com</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
    </CORSConfiguration>
t0milee commented 4 years ago

any progress on this?

SynsoftDev commented 2 years ago

Froala team, this needs to be fixed at priority. S3 upload works only for the first 5 minutes unless S3 policy is not expired.

THINGS I'VE TRIED:

Please make an event like 'imageUploadToS3.refresh()' just like we've for 'placeholder.refresh()'.