79726678

Date: 2025-08-05 23:50:49
Score: 0.5
Natty:
Report link

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);
}
Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: olliekav