This was easier than I thought 🤦♂️
I needed a route to hit with the Filepond load
method that I could pass the signed_id
to.
Add to routes.rb
get 'attachments/uploaded/:signed_id', to: 'attachments#uploaded_by_signed_id', as: :attachment_uploaded_by_signed_id
In your attachments controller (or wherever you want)
class AttachmentsController < ApplicationController
def uploaded_by_signed_id
blob = ActiveStorage::Blob.find_signed(params[:signed_id])
send_data blob.download, filename: blob.filename.to_s, content_type: blob.content_type
end
end
Then change the load method to hit this URL with the signed_id from source.
load: (source, load, error, progress, abort, headers) => {
const myRequest = new Request(`/attachments/uploaded/${source}`);
fetch(myRequest).then((res) => {
return res.blob();
}).then(load);
}