Class: Appwrite::InputFile

Inherits:
Object
  • Object
show all
Defined in:
lib/appwrite/input_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



9
10
11
# File 'lib/appwrite/input_file.rb', line 9

def data
  @data
end

#filenameObject

Returns the value of attribute filename.



6
7
8
# File 'lib/appwrite/input_file.rb', line 6

def filename
  @filename
end

#mime_typeObject

Returns the value of attribute mime_type.



7
8
9
# File 'lib/appwrite/input_file.rb', line 7

def mime_type
  @mime_type
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/appwrite/input_file.rb', line 5

def path
  @path
end

#source_typeObject

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