Monday, 30 January 2012

Paperclip: Unzip/decompress uploaded file

Very often(in a client-server API architecture) we might want to transfer compressed file data over HTTP, so gain speed over file uploads.

So, this is how the decompression code looks like in Rails 3: For a Video model, with 'data' as the paperclip attachment and opts[:data] being the uploaded file.

    tmp_fle =[:data].original_filename.to_s)
    zi =[:data]), "wb+") do |ucf|
      ucf <<
    tmp_fle.binmode = tmp_fle

Hope it works.

No comments:

Post a Comment