I am using froala editor which also has image upload to s3, I followed the steps as mentioned in the docs here
CORS configuration on s3 bucket
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
The server side code
router.route('/get_signature')
.get((req, res) => {
var configs = {
// The name of your bucket.
bucket: process.env.AWS_BUCKET_NAME,
// S3 region. If you are using the default us-east-1, it this can be ignored.
region: 'us-east-1',
// The folder where to upload the images.
keyStart: process.env.AWS_BUCKET_PROJECT_NAME + '/' + process.env.AWS_BUCKET_BLOGS,
// File access.
acl: 'public-read',
// AWS keys.
accessKey: process.env.AWS_ACCESS_KEY_ID,
secretKey: process.env.AWS_SECRET_ACCESS_KEY
}
var s3Hash = FroalaEditor.S3.getHash(configs);
console.log(JSON.stringify(s3Hash) + " :s3Hash");//this holds the s3Hash
res.send(s3Hash);
})
Get request on my client side
$.get('/blog/get_signature', {})
.done(function (s3Hash) {
console.log(JSON.stringify(s3Hash) + " :s3Hash"); //hold the response
$('textarea#froala-editor').froalaEditor({
imageUploadToS3: s3Hash,
paragraphFormat: {
h3: "Blog Title",
h4: "Abstract",
body: "Body"
},
})
.on('froalaEditor.contentChanged', function (e, editor) {
$('#preview').html(editor.html.get());
})
.on('froalaEditor.image.uploadedToS3', function (e, editor, link, key, response) {
// Image was uploaded to the server.
console.log("Image uploaded to s3 " + JSON.stringify(response));
})
})
I tried to follow the docs to perfection but the image is still not getting uploaded to s3. I don't know where I might be going wrong, I have researched and researched but did not find a proper solution to this. Any help is greatly appreciated.
I have found the solution to the question I posted above, posting an answer as it might be helpful for anyone who stumbles across this problem.
I fixed the upload issue by adding the option imageUploadUrl : false
inside the initialisation of the editor.