How to test Direct Upload in Dev Env using Shrine::Storage::FileSystem?

Hi all,

I’m currently trying to build direct upload using uppy from frontend using the :presign_endpoint plugin. I’m using Shrine::Storage::FileSystem for local development environment Shrine::Storage::GoogleCloudStorage environment. I would like to be able to test direct upload using FileSystem instead of having to pay for a test instance of cloud storage. Then for production, I can just choose the correct Shrine storage and it will work as expected.

I came across this commit (can’t put link in post for new user) from 2016 in v1.4.0 that supports dummy presign for storage systems that does not support it like Shrine::Storage::FileSystem. Looking at the code now for v3.4.1, I’m guessing this feature is no longer supported and the structure of the code base has changed tremendously.

How do you test direct upload when in development? Do you provision a test GCS or S3 for testing direct upload in local development env?

Appreciate any ideas of testing direct upload in local development environment.

Found a way to provide Presign endpoint for Filesystem. Following this code, we are able to provide our own presign generator.

# config/initializer/shrine.rb

if Rails.env.production? 
  # Using Shrine::Storage::GoogleCloudStorage in Production env so presign endpoint
  #   is already working.
  Shrine.plugin :presign_endpoint 
  # Using Shrine::Storage::FileSystem in Dev and Test env so I have to generate my own
  #   presign endpoint. This can be a fix endpoint only available in Dev and Test environment
  #   to replicate the direct upload experience. 
  Shrine.plugin :presign_endpoint, presign: -> (location, options, request) do
    # provide an endpoint for frontend to use for direct upload. 
    { endpoint: "http://localhost:3000/photos/direct_upload" }