Skip to content

Instantly share code, notes, and snippets.

@seangaffney
Created December 6, 2010 18:55
Show Gist options
  • Save seangaffney/730724 to your computer and use it in GitHub Desktop.
Save seangaffney/730724 to your computer and use it in GitHub Desktop.
Convert Tempfile to binary using binmode
# Returns representation of the data of the file assigned to the given
# style, in the format most representative of the current storage.
def to_file style = default_style
return @queued_for_write[style] if @queued_for_write[style]
filename = path(style)
extname = File.extname(filename)
basename = File.basename(filename, extname)
file = Tempfile.new([basename, extname])
file.binmode # Added
file.write(AWS::S3::S3Object.value(path(style), bucket_name))
file.rewind
return file
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment