Class: Sunrise::FileUpload::Http::QqFile
- Inherits:
-
Tempfile
- Object
- Tempfile
- Sunrise::FileUpload::Http::QqFile
- Defined in:
- lib/sunrise/file_upload/http.rb
Overview
Usage (paperclip example)
Instance Method Summary collapse
- #content_type ⇒ Object
- #fetch ⇒ Object
-
#initialize(filename, request, tmpdir = Dir::tmpdir) ⇒ QqFile
constructor
A new instance of QqFile.
- #original_filename ⇒ Object
Constructor Details
#initialize(filename, request, tmpdir = Dir::tmpdir) ⇒ QqFile
Returns a new instance of QqFile.
45 46 47 48 49 50 51 |
# File 'lib/sunrise/file_upload/http.rb', line 45 def initialize(filename, request, tmpdir = Dir::tmpdir) @original_filename = filename @request = request super Digest::SHA1.hexdigest(filename), tmpdir fetch end |
Instance Method Details
#content_type ⇒ Object
63 64 65 66 |
# File 'lib/sunrise/file_upload/http.rb', line 63 def content_type types = MIME::Types.type_for(@request.content_type) types.empty? ? @request.content_type : types.first.to_s end |
#fetch ⇒ Object
53 54 55 56 57 |
# File 'lib/sunrise/file_upload/http.rb', line 53 def fetch self.write @request.raw_post self.rewind self end |
#original_filename ⇒ Object
59 60 61 |
# File 'lib/sunrise/file_upload/http.rb', line 59 def original_filename @original_filename end |