Class: Ckeditor::Http::QqFile

Inherits:
Tempfile
  • Object
show all
Defined in:
lib/ckeditor/http.rb

Overview

Usage (paperclip example)

Instance Method Summary collapse

Constructor Details

#initialize(filename, request, tmpdir = Dir::tmpdir) ⇒ QqFile

Returns a new instance of QqFile.



43
44
45
46
47
48
49
50
# File 'lib/ckeditor/http.rb', line 43

def initialize(filename, request, tmpdir = Dir::tmpdir)
  @original_filename  = filename
  @request = request

  super Digest::SHA1.hexdigest(filename), tmpdir
  binmode
  fetch
end

Instance Method Details

#bodyObject



66
67
68
69
70
71
72
# File 'lib/ckeditor/http.rb', line 66

def body
  if @request.raw_post.respond_to?(:force_encoding)
    @request.raw_post.force_encoding("UTF-8")
  else
    @request.raw_post
  end
end

#content_typeObject



62
63
64
# File 'lib/ckeditor/http.rb', line 62

def content_type
  @request.content_type
end

#fetchObject



52
53
54
55
56
# File 'lib/ckeditor/http.rb', line 52

def fetch
  self.write(body)
  self.rewind
  self
end

#original_filenameObject



58
59
60
# File 'lib/ckeditor/http.rb', line 58

def original_filename
  @original_filename
end