Module: Mastodon::REST::Media

Includes:
Utils
Included in:
API
Defined in:
lib/mastodon/rest/media.rb

Instance Method Summary collapse

Methods included from Utils

#array_param, #perform_request, #perform_request_with_collection, #perform_request_with_object

Instance Method Details

#update_media(id, params) ⇒ Mastodon::Media

Update a media description, can only be updated while it’s not associated to a status

Parameters:

  • id (Integer)
  • params (Hash)

Options Hash (params):

  • :description (String)

    Alternative text

  • :focus (String)

    Two floating points, comma-delimited

Returns:



26
27
28
# File 'lib/mastodon/rest/media.rb', line 26

def update_media(id, params)
  perform_request_with_object(:put, "/api/v1/media/#{media_id}", params, Mastodon::Media)
end

#upload_media(file, params = {}) ⇒ Mastodon::Media

Upload a media file

Parameters:

  • file (File, StringIO, HTTP::FormData::File)
  • params (Hash) (defaults to: {})

Options Hash (params):

  • :description (String)

    Alternative text

  • :focus (String)

    Two floating points, comma-delimited

Returns:



15
16
17
18
# File 'lib/mastodon/rest/media.rb', line 15

def upload_media(file, params = {})
  file = file.is_a?(HTTP::FormData::File) ? file : HTTP::FormData::File.new(file)
  perform_request_with_object(:post, '/api/v1/media', { file: file }.merge(params), Mastodon::Media)
end