lib/twittodon/mastodon.rb
# Download url and upload to mastodon
# @param media_url [String] url for upload file
# @return [Mastodon::Media]
Download url and upload to mastodon
Download url and upload to mastodon
def upload_media_url(media_url)
      tempfile = Tempfile.open(["media", File.extname(media_url)])
      open(media_url) do |input|
        tempfile.write(input.read)
      end
      @client.upload_media(HTTP::FormData::File.new(tempfile))
    ensure
      tempfile.close! if tempfile
    end
def upload_media_url ( media_url ) tempfile = Tempfile . open ( [ "media" , File . extname ( media_url ) ] ) open ( media_url ) do | input | tempfile . write ( input . read ) end @client . upload_media ( HTTP :: FormData :: File . new ( tempfile ) ) ensure tempfile . close! if tempfile end
Download url and upload to mastodon
Download url and upload to mastodon
None
Mastodon::Media
media_url
url for upload file
url for upload file