Class: Gluttonberg::MyFile2
- Inherits:
-
File
- Object
- File
- Gluttonberg::MyFile2
- Defined in:
- app/models/gluttonberg/asset.rb
Overview
i made this class for providing extra methods in file class. I am using it for making assets from zip folder. keep in mind when we upload asset from browser, browser injects three extra attributes (that are given in MyFile class) but we are adding assets from file, i am injecting extra attributes manually. because asset library assumes that file has three extra attributes
Instance Attribute Summary (collapse)
-
- (Object) content_type
Returns the value of attribute content_type.
-
- (Object) original_filename
Returns the value of attribute original_filename.
-
- (Object) size
Returns the value of attribute size.
Class Method Summary (collapse)
Instance Attribute Details
- (Object) content_type
Returns the value of attribute content_type
138 139 140 |
# File 'app/models/gluttonberg/asset.rb', line 138 def content_type @content_type end |
- (Object) original_filename
Returns the value of attribute original_filename
138 139 140 |
# File 'app/models/gluttonberg/asset.rb', line 138 def original_filename @original_filename end |
- (Object) size
Returns the value of attribute size
138 139 140 |
# File 'app/models/gluttonberg/asset.rb', line 138 def size @size end |
Class Method Details
+ (Object) find_content_type(filename)
148 149 150 151 152 153 154 |
# File 'app/models/gluttonberg/asset.rb', line 148 def self.find_content_type(filename) begin MIME::Types.type_for(filename).first.content_type rescue "" end end |
+ (Object) init(filename)
140 141 142 143 144 145 146 |
# File 'app/models/gluttonberg/asset.rb', line 140 def self.init(filename) file = MyFile2.new(RAILS_ROOT+"/bulks/" + filename) file.original_filename = filename file.content_type = find_content_type(filename) file.size = File.size(RAILS_ROOT+"/bulks/" + filename) file end |