`

Aliyun-OSS 使用 - 图片持久化

阅读更多

Aliyun OSS 使用 - 图片持久化

参考:aliyun-sdk Ruby版本

 

uri       = URI('https://<bucket>.oss-cn-beijing.aliyuncs.com/img/62ed226d-5673-4e12-8c0a-9734ac570893_02.jpg')
      uri.query = 'x-oss-process'

      header                 = {}
      header['content-type'] = 'application/x-www-form-urlencoded'
      header['date']         = Time.now.httpdate
      header['user-agent']   = 'aliyun-sdk-ruby/0.7.1 ruby-2.6.3/x86_64-darwin17'

      cano_res                = {path: "/#{aliyun_bucket}/img/62ed226d-5673-4e12-8c0a-9734ac570893_02.jpg", sub_res: {'x-oss-process' => nil}}
      sig                     = Aliyun::OSS::Util.get_signature(aliyun_access_key_secret, 'POST', header, cano_res)
      header['authorization'] = "OSS #{aliyun_access_key_id}:#{sig}"

      res = RestClient.post(uri.to_s, {'x-oss-process' => process_str}, header)

 

 

# _http: #<Aliyun::OSS::HTTP:0x00007f7f81e27478>    
 
res   = _http.post(
        {bucket: aliyun_bucket, object: self.path, sub_res: {'x-oss-process' => nil}},
        {headers: {'content-type' => 'application/x-www-form-urlencoded'},
         body:    RestClient::Payload::UrlEncoded.new('x-oss-process' => process_str)}
      )

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics