Skip to content

Commit 746a1b3

Browse files
authored
Use open-uri to open uri as file (#438)
1 parent a5ec17f commit 746a1b3

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/yt/models/account.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'open-uri'
12
require 'yt/models/base'
23

34
module Yt
@@ -73,7 +74,7 @@ def avatar_url
7374
# @option params [Boolean] :self_declared_made_for_kids The video’s made for kids self-declaration.
7475
# @return [Yt::Models::Video] the newly uploaded video.
7576
def upload_video(path_or_url, params = {})
76-
file = URI.open(path_or_url)
77+
file = URI.parse(path_or_url).open
7778
session = resumable_sessions.insert file.size, upload_body(params)
7879

7980
session.update(body: file) do |data|

lib/yt/models/video.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def claim
546546
# @raise [Yt::Errors::RequestError] if path_or_url is not a valid path
547547
# or URL.
548548
def upload_thumbnail(path_or_url)
549-
file = URI.open(path_or_url) rescue StringIO.new
549+
file = URI.parse(path_or_url).open rescue StringIO.new
550550
session = resumable_sessions.insert file.size
551551

552552
session.update(body: file) do |data|

0 commit comments

Comments
 (0)