Use custom HTTP headers on upload


I went through the docs and issues, but could not find the answer to my question.

I’ve got a rails app, and need to send a custom HTTP headers to my openstack/swift backend, to override default behavior, namely : Content-Disposition: inline (on file upload).

I will want to override other behaviors as well, via other HTTP headers.

My initialiser looks something like this:

Shrine.storages = {
  store: #permanent
    provider: "OpenStack",
    directory: directory,

    openstack_auth_url:  ENV.fetch('OS_AUTH_URL'),
    openstack_region:    ENV.fetch('OS_REGION_NAME'),

    openstack_tenant:    ENV.fetch('OS_TENANT_NAME'),

    openstack_username:  ENV.fetch('OS_USERNAME'),
    openstack_api_key:   ENV.fetch('OS_PASSWORD'),

    # swift post -m "Temp-URL-Key: 12345"
    openstack_temp_url_key: ENV.fetch('OS_TEMP_URL_KEY'),

Shrine.plugin :activerecord

I’m confused about how one would do this? The closest thing I could find is implementing some kind of endpoint, but that’s not what I want: I’d like to only add HTTP headers on upload, from the rails server, to the cloud backend.

We’ll need to first figure out how to pass HTTP headers using Fog directly. Then hopefully the solution for shrine-fog will become obvious. If you help me figure out the Fog part, I can help figure out the shrine-fog part. :wink:

It appears these are the options for specifying headers –

So, I believe the following configuration should do it:

Shrine.plugin :upload_options, store: {
  content_disposition: "inline",