Skip to content

Commit

Permalink
Allow setting alt_text for uploaded media
Browse files Browse the repository at this point in the history
  • Loading branch information
rockshassa committed Nov 4, 2024
1 parent 721898b commit db51856
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/x/media_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def await_processing(client:, media:)
end
end

def set_alt_text(client:, media_id:, alt_text:)
post_body = "{ \"media_id\" : \"#{media_id}\", \"alt_text\" : { \"text\" : \"#{alt_text}\" } }"
headers = {"Content-Type" => "application/json"}
upload_client = client.dup.tap { |c| c.base_url = "https://upload.twitter.com/1.1/" }
upload_client.post("media/metadata/create.json", post_body, headers:)
end

private

def validate!(file_path:, media_category:)
Expand Down

0 comments on commit db51856

Please sign in to comment.