Module: Mastodon::REST::Media
Instance Method Summary collapse
-
#update_media_description(media_id, description) ⇒ Mastodon::Media
Update a media description, can only be updated while it’s not associated to a status.
-
#update_media_focus(media_id, focus_x, focus_y) ⇒ Mastodon::Media
Update a media focal point, can only be updated while it’s not associated to a status.
-
#upload_media(file, description = nil, *focus) ⇒ Mastodon::Media
Upload a media file.
Methods included from Utils
#array_param, #perform_request, #perform_request_with_collection, #perform_request_with_object
Instance Method Details
#update_media_description(media_id, description) ⇒ Mastodon::Media
Update a media description, can only be updated while it’s not
associated to a status
38 39 40 41 42 |
# File 'lib/mastodon/rest/media.rb', line 38 def update_media_description(media_id, description) perform_request_with_object(:put, "/api/v1/media/#{media_id}", { description: description }, Mastodon::Media) end |
#update_media_focus(media_id, focus_x, focus_y) ⇒ Mastodon::Media
Update a media focal point, can only be updated while it’s not
associated to a status
50 51 52 53 54 |
# File 'lib/mastodon/rest/media.rb', line 50 def update_media_focus(media_id, focus_x, focus_y) perform_request_with_object(:put, "/api/v1/media/#{media_id}", { focus: "#{focus_x},#{focus_y}" }, Mastodon::Media) end |
#upload_media(file, description = nil, *focus) ⇒ Mastodon::Media
Upload a media file
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mastodon/rest/media.rb', line 19 def upload_media(file, description = nil, *focus) file = if file.is_a?(HTTP::FormData::File) file else HTTP::FormData::File.new(file) end payload = { file: file } payload[:description] = description unless description.nil? payload[:focus] = focus.collect{|f| f.to_s}.join(',') unless focus.nil? perform_request_with_object(:post, '/api/v1/media', payload, Mastodon::Media) end |