I have a rails 6 app using ActiveStorage (image attached to article) and froala editor. Both upload to S3.
But I currently use the froala S3 upload and active storage. In the form, I have:
- an upload button, that allows uploading a pdf file and
- a text field with froala where images can be uploaded
Active Storage
class Article < ApplicationRecord
belongs_to :author
has_one_attached :image
#ArticleController
@article.image.attach(params[:image])
Froala:
# class Adm::ArticleController < ApplicationController
def new
#....
@aws_data = FroalaEditorSDK::S3.data_hash(Article.froalaoptions)
end
end
and initialise in javascript:
var editor = new FroalaEditor('#article_contenu',{
attribution: false,
height: 330,
key: "mykey",
iframeStyleFiles: ['my.css'],
pluginsEnabled: ['image'],
imageUploadToS3: <%= @aws_data.to_json.html_safe %>,
saveURL: '<%= adm_auteur_article_autosave_url %>',
saveMethod: 'POST'
});
I would like to do something like:
var editor = new FroalaEditor('#article_contenu',{
attribution: false,
height: 330,
key: "mykey",
iframeStyleFiles: ['my.css'],
pluginsEnabled: ['image'],
// imageUploadToS3: <%= @aws_data.to_json.html_safe %>,
saveURL: '<%= rails_blob_path(article.image, disposition: "attachment")%>
});
Is there a way to use Rails Active Storage to upload files in the froala editor, similar to Rails ActionText where an image uploaded in the trix editor is stored in ActiveStorage?