Skip to content

Instantly share code, notes, and snippets.

@amalagaura
Created April 24, 2011 19:16
Show Gist options
  • Save amalagaura/939806 to your computer and use it in GitHub Desktop.
Save amalagaura/939806 to your computer and use it in GitHub Desktop.
Monkey patch idea to get streaming uploads for carrierwave
module CarrierWave
module Storage
class S3
class File
def store(file)
content_type ||= file.content_type # this might cause problems if content type changes between read and upload (unlikely)
connection.put_object(bucket, path, file.open,
{
'x-amz-acl' => access_policy.to_s.gsub('_', '-'),
'Content-Type' => content_type
}.merge(@uploader.s3_headers)
)
end
end
end
end
end
module CarrierWave
class SanitizedFile
def open
File.open(@file)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment