fog / fog-rackspace

Rackspace provider gem for Fog ecosystem
MIT License
8 stars 35 forks source link

Files#get with block has incorrect data when writing a gzip file #5

Closed plribeiro3000 closed 8 years ago

plribeiro3000 commented 8 years ago

When using the fog storage rackspace cloud files Files#get method http://www.rubydoc.info/github/fog/fog/Fog/Storage/Rackspace/Files#get-instance_method to retrieve a gzipped tar file (file.tar.gz) using the example shown in the link with a block and writing the data to the file, the resulting file is not of the correct content type. Trying "file file.tar.gz" results in "file.tar.gz: data". If I retrieve the same file by allowing the method to return an object, then write the object.body to a file it writes correctly and the command "file file.tar.gz" results in "file.tar.gz: gzip compressed data, from Unix, last modified: Fri Aug 14 11:37:29 2015" as expected. Using the block method on a simple text file seems to work fine. Is this a bug or am I doing something wrong? I thought perhaps there was a different approach needed if the file was binary but the example in the link above shows the block method on an image file so I assume it should work for binary files, no?

Original issue opened by @patakijv at fog/fog#3663.

plribeiro3000 commented 8 years ago

cc/ @patakijv @geemus

mdarby commented 8 years ago

@patakijv is this still an issue?

patakijv commented 8 years ago

I haven't tested recently. Have there been changes made over the past year that should change this behavior?

mdarby commented 8 years ago

You might want to if you're interested; my quick test (from what I understand) seems to behave correctly?

require 'fog'
require 'pry'

storage = Fog::Storage.new(
  :provider           => 'Rackspace',
  :rackspace_api_key  => ENV['RS_API_KEY'],
  :rackspace_username => ENV['RS_USERNAME']
)

directory = storage.directories.get('test')

File.open('~/local.tar.gz', 'w') do |f|
  directory.files.get("remote.tar.gz") do |data, remaing, content_length|
    f.syswrite data
  end
end

I'm just trying to close up severely old tickets. :)