fog / fog-openstack

Fog for OpenStack Platform
MIT License
68 stars 130 forks source link

X-Copy-From request send "application/json" as content type #512

Open nhh opened 4 years ago

nhh commented 4 years ago

I am processing videos with carrierwave and fog as storage provider. All videos that are uploaded have the content type "application/json". I already got so far, that i have overriden the CarrierWave::Storage::Fog::File#content_type method but with no success. With that tried i've come to the conclusion, that there is something wrong underneath my processing code.

What i can see with EXCON_DEBUG=true is, that the first request, putting my video into a temp file, works as expected:

:method              => "PUT"
:headers             => {
    "Accept"         => "application/json"
    "Content-Length" => 3267624
    "Content-Type"   => "video/quicktime"
    "Host"           => "storage.sbg.cloud.ovh.net:443"
    "User-Agent"     => "fog-core/2.2.0"
    "X-Auth-Token"   => "XXXXXXXX"
}

I get a 201 Created back. After that, carrierwave processes the file and moves it with fog-openstack into is real destination:

:headers             => {
    "Accept"       => "application/json"
    "Content-Type" => "application/json"
    "Host"         => "storage.sbg.cloud.ovh.net:443"
    "User-Agent"   => "fog-core/2.2.0"
    "X-Auth-Token" => "XXXXXXXX"
    "X-Copy-From"  => "/XXXX_development/uploads/tmp/1590760935-202723548356984-0001-0409/loading_screen_flickers.mov"
  }

The response for the copy request looks as following:

  :headers       => {
    "Content-Length"              => "0"
    "Content-Type"                => "text/html; charset=UTF-8"
    "Date"                        => "Fri, 29 May 2020 14:02:20 GMT"
    "Etag"                        => "e1340ff8ddfb1a8ae1252bc55dae7f85"
    "Last-Modified"               => "Fri, 29 May 2020 14:02:20 GMT"
    "X-Copied-From"               => "XXX_development/uploads/tmp/1590760935-202723548356984-0001-0409/loading_screen_flickers.mov"
    "X-Copied-From-Account"       => "XXXXXXXXXXXX"
    "X-Copied-From-Last-Modified" => "Fri, 29 May 2020 14:02:18 GMT"
    "X-IPLB-Instance"             => "12631"
    "X-Openstack-Request-Id"      => "tx3905d22b0674473e9bd0f-005ed115eb"
    "X-Trans-Id"                  => "tx3905d73b0671173e9bd0f-005ed115eb"
  }

After that, the file which got moved will only be accessible via content type "application/json".

Any ideas?

Best, Niklas

cutalion commented 3 years ago

I have the same issue with fog-core 1.45.0, fog-openstack 0.3.10 and carrierwave 2.1.0. I had to set local cache (cache_storage :file) in carrierwave not to move files remotely via X-Copy-From header