@petergoldstein this pr doesn't actually look too complicated once it's cleaned up to target master.  I believe this is the only bit of code really needing to be tested.  Just making sure that depending on the setting you get the right redirect or send file.  Although I'm not sure why a redirect_to is necessary.  I would think that you could do send_file with S3 I'm almost certain I've done it before.  /cc @Grantismo