Module: Mattermost::Endpoint::Files

Included in:
Mattermost::Endpoint
Defined in:
lib/mattermost/endpoint/files.rb

Instance Method Summary collapse

Instance Method Details

#get_file(file_id, file_name) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/mattermost/endpoint/files.rb', line 12

def get_file(file_id, file_name)
	File.open(file_name, "w") do |file|
		file.binmode
		get(get_file_url(file_id), stream_body: true) do |fragment|
			file.write(fragment)
		end
	end
end

#get_file_preview(file_id, file_name) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/mattermost/endpoint/files.rb', line 38

def get_file_preview(file_id, file_name)
	File.open(file_name, "w") do |file|
		file.binmode
		get(get_file_preview_url(file_id), stream_body: true) do |fragment|
			file.write(fragment)
		end
	end
end

#get_file_preview_url(file_id) ⇒ Object



47
48
49
# File 'lib/mattermost/endpoint/files.rb', line 47

def get_file_preview_url(file_id)
	"/files/#{file_id}/preview"
end

#get_file_thumbnail(file_id, file_name) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/mattermost/endpoint/files.rb', line 25

def get_file_thumbnail(file_id, file_name)
	File.open(file_name, "w") do |file|
		file.binmode
		get(get_file_thumbnail_url(file_id), stream_body: true) do |fragment|
			file.write(fragment)
		end
	end
end

#get_file_thumbnail_url(file_id) ⇒ Object



34
35
36
# File 'lib/mattermost/endpoint/files.rb', line 34

def get_file_thumbnail_url(file_id)
	"/files/#{file_id}/thumbnail"
end

#get_file_url(file_id) ⇒ Object



21
22
23
# File 'lib/mattermost/endpoint/files.rb', line 21

def get_file_url(file_id)
	"/files/#{file_id}"
end

#get_metadata_for_file(file_id) ⇒ Object



55
56
57
# File 'lib/mattermost/endpoint/files.rb', line 55

def (file_id)
	get("/files/#{file_id}/info")
end


51
52
53
# File 'lib/mattermost/endpoint/files.rb', line 51

def get_public_file_link(file_id)
	get("/files/#{file_id}/link")
end

#upload_file(file, channel_id) ⇒ Object

Raises:

  • (NotImplementedError)


7
8
9
10
# File 'lib/mattermost/endpoint/files.rb', line 7

def upload_file(file, channel_id)
	#post("/files, file)
	raise NotImplementedError
end