Class: Appwrite::InputFile
- Inherits:
-
Object
- Object
- Appwrite::InputFile
- Defined in:
- lib/appwrite/input_file.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#mime_type ⇒ Object
Returns the value of attribute mime_type.
-
#path ⇒ Object
Returns the value of attribute path.
-
#source_type ⇒ Object
Returns the value of attribute source_type.
Class Method Summary collapse
- .from_bytes(bytes, filename: nil, mime_type: nil) ⇒ Object
- .from_path(path) ⇒ Object
- .from_string(string, filename: nil, mime_type: nil) ⇒ Object
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/appwrite/input_file.rb', line 9 def data @data end |
#filename ⇒ Object
Returns the value of attribute filename.
6 7 8 |
# File 'lib/appwrite/input_file.rb', line 6 def filename @filename end |
#mime_type ⇒ Object
Returns the value of attribute mime_type.
7 8 9 |
# File 'lib/appwrite/input_file.rb', line 7 def mime_type @mime_type end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/appwrite/input_file.rb', line 5 def path @path end |
#source_type ⇒ Object
Returns the value of attribute source_type.
8 9 10 |
# File 'lib/appwrite/input_file.rb', line 8 def source_type @source_type end |
Class Method Details
.from_bytes(bytes, filename: nil, mime_type: nil) ⇒ Object
29 30 31 |
# File 'lib/appwrite/input_file.rb', line 29 def self.from_bytes(bytes, filename: nil, mime_type: nil) self.from_string(bytes.pack('C*'), filename: filename, mime_type: mime_type) end |
.from_path(path) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/appwrite/input_file.rb', line 11 def self.from_path(path) instance = InputFile.new instance.path = path instance.filename = ::File.basename(path) instance.mime_type = MIME::Types.type_for(path).first.content_type instance.source_type = 'path' instance end |
.from_string(string, filename: nil, mime_type: nil) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/appwrite/input_file.rb', line 20 def self.from_string(string, filename: nil, mime_type: nil) instance = InputFile.new instance.data = string instance.filename = filename instance.mime_type = mime_type instance.source_type = 'string' instance end |