aliyun / aliyun-oss-ruby-sdk

Aliyun OSS SDK for Ruby
http://www.rubydoc.info/gems/aliyun-sdk/
MIT License
140 stars 67 forks source link

无法上传tar.gz 文件 #76

Open sunjirui opened 5 years ago

sunjirui commented 5 years ago
client = Aliyun::OSS::Client.new(
  :endpoint => 'https://oss-cn-beijing.aliyuncs.com',
  :access_key_id => 'xxxxx',
  :access_key_secret => 'xxxxx')

bucket = client.get_bucket('xxx')

local_file = File.open("xxx.bak.tar.gz")
bucket.put_object('demo', :file => local_file)

 返回
 invalid byte sequence in UTF-8
 经查找在
  def get_content_type(file)
    t = MIME::Types.of(file)
    t.first.content_type unless t.empty?
  end
  中 的 t = MIME::Types.of(file)报错
witcan commented 4 years ago

transform: local_file = File.open("xxx.bak.tar.gz") into: local_file = File.open("xxx.bak.tar.gz").path