I can successfully upload image to Amazon S3 using direct Upload but if I remove the image from the Trix rich text it doesn't being deleted from S3 server. I suppose I should do something similar as trix-attachment-remove.
Why this is not default in Rails 6?
application.js
//= require activestorage
document.addEventListener('trix-attachment-add', function (event) {
var file = event.attachment.file;
if (file) {
var upload = new window.ActiveStorage.DirectUpload(file,'/rails/active_storage/direct_uploads', window);
upload.create((error, attributes) => {
if (error) {
return false;
} else {
return event.attachment.setAttributes({
url: `/rails/active_storage/blobs/${attributes.signed_id}/${attributes.filename}`,
href: `/rails/active_storage/blobs/${attributes.signed_id}/${attributes.filename}`,
});
}
});
}
});