Class: Ckeditor::Http::QqFile

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

Overview

Usage (paperclip example)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, request) ⇒ QqFile

Returns a new instance of QqFile.



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

def initialize(filename, request)
  @original_filename = filename
  @request = request

  super(Digest::SHA1.hexdigest(filename))
  fetch
end

Instance Attribute Details

#original_filenameObject (readonly)

Returns the value of attribute original_filename.



43
44
45
# File 'lib/ckeditor/http.rb', line 43

def original_filename
  @original_filename
end

Instance Method Details

#bodyObject



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

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



60
61
62
# File 'lib/ckeditor/http.rb', line 60

def content_type
  @request.content_type
end

#fetchObject



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

def fetch
  binmode
  write(body)
  rewind
  self
end