wysiwyg-rails icon indicating copy to clipboard operation
wysiwyg-rails copied to clipboard

S3 Wrong URL formed which says CORS issue

Open aashishpsaini opened this issue 3 years ago • 1 comments

In the recent amazon updates, there are a couple of changes in the AWS S3 API which is failing the S3 image upload in the editor. When we upload an image it throws an error saying Parsing failed with status as CORS error. As per the docs, the correct URL format is: https://<bucket-name>.s3.<region>.amazonaws.com

And the current URL formed is https://<region>.amazonaws.com/<bucket-name>

I had a look at the minified JS which computes this as: A.opts.imageUploadToS3 && (s = A.opts.imageUploadToS3.uploadURL ? A.opts.imageUploadToS3.uploadURL : "https://".concat(A.opts.imageUploadToS3.region, ".amazonaws.com/").concat(A.opts.imageUploadToS3.bucket)),

I believe this is a simple change and should be looked on a priority as things are breaking currently.

aashishpsaini avatar Mar 12 '21 11:03 aashishpsaini

For me the error is 400 bad request.

I have followed these instructions, but no luck. https://froala.com/wysiwyg-editor/docs/sdks/ruby/file-s3-upload/

The URL can be modified this way:

# in your controller or helper
hash = FroalaEditorSDK::S3.data_hash(options)
hash[:uploadURL] = 'https://your-bucket.s3.your-region.amazonaws.com/'
return hash

But still doesn't work - still got 400 bad request.

I guess the lib and the docs are both very outdated? Please update these issues. Thank you.

planetaska avatar Oct 21 '22 07:10 planetaska