I’ve managed to figure out how to do it, though it feels a bit messy:
image = ActiveStorage::Blob.create_and_upload!(
io: params[:file],
filename: params[:file].original_filename,
content_type: params[:file].content_type
)
page.images.attach image
render json: { link: rails_blob_path(image), 'data-signed-id': image.signed_id }
Props to this article: Manual uploads using Active Storage | by Mirko Akov | Evermore | Medium