Shrine

How to direct upload an image directly to an external URL (not S3)?

Hey all! Had a doubt - and wanted to check if this is doable before beginning to code.

Can I use Shrine to direct upload an image directly to an external URL (not S3) using a multipart form POST request.

The URL is custom and created already in the app - and one can upload an image to the URL using a multipart form, and by including the necessary parameters as form inputs in the POST request body.

My question is this: Can I automatically upload an image added by a user to this URL via shrine? Without Shrine, I can upload the image to this URL - but it goes from user → to my server → to the URL. I want to go directly from user to the URL - and avoid saving the file twice.

I am thinking using Shrine’s upload endpoint - I should be able to do this. Possible steps:

Steps:

  1. Allow user to upload image
  2. Pass the upload URL to shrine upload endpoint (using JS)
  3. Upload the image using multipart form POST request. (Using JS)

Just wanted to check if this is doable? Have not used Shrine before. Familiar with Active Storage - but imo ActiveStorage does not allow you to upload an image to a URL using multipart POST requests.

Any feedback on this? Thank you!

Thinking I should be able to do this by

  1. Using Upload Endpoint
  2. Using Uppy’s XHR Upload

Is it possible to change the upload endpoint for each file with a custom URL?