carrierwave-aliyun 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +10 -0
- data/README.md +27 -13
- data/lib/carrierwave-aliyun.rb +13 -7
- data/lib/carrierwave/aliyun/bucket.rb +98 -82
- data/lib/carrierwave/aliyun/configuration.rb +12 -3
- data/lib/carrierwave/aliyun/version.rb +3 -1
- data/lib/carrierwave/storage/aliyun.rb +1 -3
- data/lib/carrierwave/storage/aliyun_file.rb +11 -9
- metadata +6 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d76d49aaf688f569f6ad24269872e9ff3a773590d63533c472e5fe570bc673ab
|
4
|
+
data.tar.gz: 4a6d40ae6c492edb56fd5804ee7b69ff89cddbc88143f95dc7b2aa5bd8a6a898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 478a675dbb9dd3eaea1049c6a33dd892c5ff1458c615c1dff4d0eb6c4eb6a61cb8227bb7fb8d327679fed4cc29c24890ee1fb59399e431b2d845d2afa9960170
|
7
|
+
data.tar.gz: 935fc2b025cb985d5133b198d7aa82e3baec7e7328bea7b33152b2dd90efc753df3c94a407fa102f9bb88465b41cd35e0b953728b49f0956ed24f8ab15ac1e0e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 1.0.0
|
2
|
+
|
3
|
+
- 采用 Aliyun 官方的 SDK 来访问 OSS;
|
4
|
+
- DEPRECATION: 配置参数命名规范化,老的配置方式将会在 1.1.0 版本废弃,请注意替换:
|
5
|
+
- `aliyun_access_id` -> `aliyun_access_key_id`
|
6
|
+
- `aliyun_access_key` -> `aliyun_access_key_secret`
|
7
|
+
- `aliyun_area` -> `aliyun_region`
|
8
|
+
- `aliyun_private_read` -> `aliyun_mode = :private`
|
9
|
+
- 改进文件上传,支持 `chunk` 模式上传,提升大文件上传的效率以及降低内存开销;
|
10
|
+
|
1
11
|
## 0.9.0
|
2
12
|
|
3
13
|
- 修正 `AliyunFile#read` 方法会报错的问题。(#53)
|
data/README.md
CHANGED
@@ -4,7 +4,9 @@ This gem adds support for [Aliyun OSS](http://oss.aliyun.com) to [CarrierWave](h
|
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/carrierwave-aliyun.svg)](https://rubygems.org/gems/carrierwave-aliyun) [![Build Status](https://travis-ci.org/huacnlee/carrierwave-aliyun.svg?branch=master)](https://travis-ci.org/huacnlee/carrierwave-aliyun) [![Code Climate](https://codeclimate.com/github/huacnlee/carrierwave-aliyun/badges/gpa.svg)](https://codeclimate.com/github/huacnlee/carrierwave-aliyun)
|
6
6
|
|
7
|
-
> NOTE: 此 Gem 是一个 CarrierWave 的组件,你需要配合 CarrierWave 一起使用,如果你需要直接用 Aliyun OSS,可以尝试用 [aliyun-
|
7
|
+
> NOTE: 此 Gem 是一个 CarrierWave 的组件,你需要配合 CarrierWave 一起使用,如果你需要直接用 Aliyun OSS,可以尝试用 [aliyun-sdk](https://github.com/aliyun/aliyun-oss-ruby-sdk) 这个 Gem。
|
8
|
+
|
9
|
+
> NOTE: This gem is a extends for [CarrierWave](https://github.com/jnicklas/carrierwave/) for allow it support use Alicloud OSS as storage backend, if you wants use Alicloud OSS directly, please visit [aliyun-sdk](https://github.com/aliyun/aliyun-oss-ruby-sdk).
|
8
10
|
|
9
11
|
## Using Bundler
|
10
12
|
|
@@ -14,33 +16,42 @@ gem 'carrierwave-aliyun'
|
|
14
16
|
|
15
17
|
## Configuration
|
16
18
|
|
17
|
-
|
19
|
+
You need a `config/initializers/carrierwave.rb` for initialize, and update your configurations:
|
18
20
|
|
19
21
|
```ruby
|
20
22
|
CarrierWave.configure do |config|
|
21
23
|
config.storage = :aliyun
|
22
|
-
config.
|
23
|
-
config.
|
24
|
-
# 你需要在
|
24
|
+
config.aliyun_access_key_id = "xxxxxx"
|
25
|
+
config.aliyun_access_key_secret = 'xxxxxx'
|
26
|
+
# 你需要在 Aliyun OSS 上面提前创建一个 Bucket
|
27
|
+
# You must create a Bucket on Alicloud OSS first.
|
25
28
|
config.aliyun_bucket = "simple"
|
26
29
|
# 是否使用内部连接,true - 使用 Aliyun 主机内部局域网的方式访问 false - 外部网络访问
|
30
|
+
# When your app server wants deployment in Alicloud internal network, enable this option can speed up uploading by using internal networking. otherwice you must disable it.
|
27
31
|
config.aliyun_internal = true
|
28
|
-
# 配置存储的地区数据中心,默认: cn-hangzhou
|
29
|
-
#
|
32
|
+
# 配置存储的地区数据中心,默认: "cn-hangzhou"
|
33
|
+
# Which region of your Bucket.
|
34
|
+
# config.aliyun_region = "cn-hangzhou"
|
30
35
|
# 使用自定义域名,设定此项,carrierwave 返回的 URL 将会用自定义域名
|
31
36
|
# 自定义域名请 CNAME 到 you_bucket_name.oss-cn-hangzhou.aliyuncs.com (you_bucket_name 是你的 bucket 的名称)
|
37
|
+
# aliyun_host allow you config a custom host for your Alicloud Bucket, and you also need config that on Alicloud.
|
32
38
|
config.aliyun_host = "https://foo.bar.com"
|
33
39
|
# Bucket 为私有读取请设置 true,默认 false,以便得到的 URL 是能带有 private 空间访问权限的逻辑
|
34
|
-
#
|
40
|
+
# Tell SDK the privacy of you Bucket, if private CarrierWave xxx.url will generate URL with a expires parameter, default: :public.
|
41
|
+
# config.aliyun_mode = :private
|
35
42
|
end
|
36
43
|
```
|
37
44
|
|
38
|
-
## 阿里云 OSS 图片缩略图
|
45
|
+
## 阿里云 OSS 图片缩略图 / About the image Thumb service for Alicloud OSS
|
39
46
|
|
40
47
|
> NOTE: 此方法同样支持 Private 的 Bucket 哦!
|
41
48
|
|
49
|
+
> NOTE: Private Bucket also support this feature!
|
50
|
+
|
42
51
|
关于阿里云 OSS 图片缩略图的详细文档,请仔细阅读: [Aliyun OSS 接入图片服务](https://help.aliyun.com/document_detail/44688.html)
|
43
52
|
|
53
|
+
The details of the Alicoud OSS image thumb service, please visit [Alicloud OSS - Image Processing / Resize images](https://www.alibabacloud.com/help/doc-detail/44688.htm)
|
54
|
+
|
44
55
|
```rb
|
45
56
|
irb> User.last.avatar.url(thumb: '?x-oss-process=image/resize,h_100')
|
46
57
|
"https://simple.oss-cn-hangzhou.aliyuncs.com/users/avatar/12.png?x-oss-process=image/resize,h_100"
|
@@ -48,21 +59,24 @@ irb> User.last.avatar.url(thumb: '?x-oss-process=image/resize,h_100,w_100')
|
|
48
59
|
"https://simple.oss-cn-hangzhou.aliyuncs.com/users/avatar/12.png?x-oss-process=image/resize,h_100,w_100"
|
49
60
|
```
|
50
61
|
|
51
|
-
## 增对文件设置 Content-Disposition
|
62
|
+
## 增对文件设置 Content-Disposition / Customize the Content-Disposition
|
52
63
|
|
53
|
-
在文件上传的场景(非图片),你可能需要给上传的文件设置 Content-Disposition 以便于用户直接访问 URL 的时候能够用你期望的文件名或原文件名来下载并保存。
|
64
|
+
在文件上传的场景(非图片),你可能需要给上传的文件设置 `Content-Disposition` 以便于用户直接访问 URL 的时候能够用你期望的文件名或原文件名来下载并保存。
|
65
|
+
|
66
|
+
In some case, you may need change the `Content-Disposition` for your uploaded files for allow users visit URL with direct download, and get the original filename.
|
54
67
|
|
55
68
|
这个时候你需要给 Uploader 实现 `content_disposition` 函数,例如:
|
56
69
|
|
70
|
+
So, you need implement a `content_disposition` method for your CarrierWave Uploader, for example:
|
71
|
+
|
57
72
|
```rb
|
58
73
|
# app/uploaders/attachment_uploader.rb
|
59
74
|
class AttachmentUploader < CarrierWave::Uploader::Base
|
60
75
|
def content_disposition
|
61
|
-
#
|
76
|
+
# Only for non-image files
|
62
77
|
unless file.extension.downcase.in?(%w(jpg jpeg gif png svg))
|
63
78
|
"attachment;filename=#{file.original_filename}"
|
64
79
|
end
|
65
80
|
end
|
66
81
|
end
|
67
|
-
|
68
82
|
```
|
data/lib/carrierwave-aliyun.rb
CHANGED
@@ -1,13 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "carrierwave"
|
4
|
+
require "carrierwave/storage/aliyun"
|
5
|
+
require "carrierwave/storage/aliyun_file"
|
6
|
+
require "carrierwave/aliyun/bucket"
|
7
|
+
require "carrierwave/aliyun/version"
|
8
|
+
require "carrierwave/aliyun/configuration"
|
9
|
+
require "aliyun/oss"
|
6
10
|
|
7
11
|
CarrierWave::Uploader::Base.send(:include, CarrierWave::Aliyun::Configuration)
|
8
12
|
|
9
|
-
if CarrierWave::VERSION <=
|
10
|
-
require
|
13
|
+
if CarrierWave::VERSION <= "0.11.0"
|
14
|
+
require "carrierwave/processing/mime_types"
|
11
15
|
CarrierWave::Uploader::Base.send(:include, CarrierWave::MimeTypes)
|
12
16
|
CarrierWave::Uploader::Base.send(:process, :set_content_type)
|
13
17
|
end
|
18
|
+
|
19
|
+
Aliyun::Common::Logging.set_log_file("/dev/null")
|
@@ -1,22 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module CarrierWave
|
2
4
|
module Aliyun
|
3
5
|
class Bucket
|
4
6
|
PATH_PREFIX = %r{^/}
|
7
|
+
CHUNK_SIZE = 1024 * 1024
|
8
|
+
|
9
|
+
attr_reader :access_key_id, :access_key_secret, :bucket, :region, :mode, :host
|
10
|
+
|
11
|
+
attr_reader :endpoint, :img_endpoint, :upload_endpoint
|
5
12
|
|
6
13
|
def initialize(uploader)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
14
|
+
if uploader.aliyun_area.present?
|
15
|
+
ActiveSupport::Deprecation.warn("config.aliyun_area will deprecation in carrierwave-aliyun 1.1.0, please use `aliyun_region` instead.")
|
16
|
+
uploader.aliyun_region ||= uploader.aliyun_area
|
17
|
+
end
|
18
|
+
|
19
|
+
if uploader.aliyun_private_read != nil
|
20
|
+
ActiveSupport::Deprecation.warn(%(config.aliyun_private_read will deprecation in carrierwave-aliyun 1.1.0, please use `aliyun_mode = :private` instead.))
|
21
|
+
uploader.aliyun_mode ||= uploader.aliyun_private_read ? :private : :public
|
22
|
+
end
|
23
|
+
|
24
|
+
if uploader.aliyun_access_id.present?
|
25
|
+
ActiveSupport::Deprecation.warn(%(config.aliyun_access_id will deprecation in carrierwave-aliyun 1.1.0, please use `aliyun_access_key_id` instead.))
|
26
|
+
uploader.aliyun_access_key_id ||= uploader.aliyun_access_id
|
27
|
+
end
|
28
|
+
|
29
|
+
if uploader.aliyun_access_key.present?
|
30
|
+
ActiveSupport::Deprecation.warn(%(config.aliyun_access_key will deprecation in carrierwave-aliyun 1.1.0, please use `aliyun_access_key_secret` instead.))
|
31
|
+
uploader.aliyun_access_key_secret ||= uploader.aliyun_access_key
|
32
|
+
end
|
33
|
+
|
34
|
+
@access_key_id = uploader.aliyun_access_key_id
|
35
|
+
@access_key_secret = uploader.aliyun_access_key_secret
|
36
|
+
@bucket = uploader.aliyun_bucket
|
37
|
+
@region = uploader.aliyun_region || "cn-hangzhou"
|
38
|
+
@mode = (uploader.aliyun_mode || :public).to_sym
|
13
39
|
|
14
40
|
# Host for get request
|
15
|
-
@
|
41
|
+
@host = uploader.aliyun_host || "https://#{self.bucket}.oss-#{self.region}.aliyuncs.com"
|
16
42
|
|
17
|
-
unless @
|
18
|
-
raise "config.aliyun_host requirement include // http:// or https://, but you give: #{
|
43
|
+
unless @host.include?("//")
|
44
|
+
raise "config.aliyun_host requirement include // http:// or https://, but you give: #{self.host}"
|
19
45
|
end
|
46
|
+
|
47
|
+
@endpoint = "https://oss-#{self.region}.aliyuncs.com"
|
48
|
+
@upload_endpoint = uploader.aliyun_internal == true ? "https://oss-#{self.region}-internal.aliyuncs.com" : @endpoint
|
49
|
+
@img_endpoint = "https://img-#{self.region}.aliyuncs.com"
|
20
50
|
end
|
21
51
|
|
22
52
|
# 上传文件
|
@@ -28,21 +58,20 @@ module CarrierWave
|
|
28
58
|
# - content_disposition - Content-Disposition
|
29
59
|
# returns:
|
30
60
|
# 图片的下载地址
|
31
|
-
def put(path, file,
|
32
|
-
path.sub
|
61
|
+
def put(path, file, content_type: "image/jpg", content_disposition: nil)
|
62
|
+
path = path.sub(PATH_PREFIX, "")
|
33
63
|
|
34
64
|
headers = {}
|
35
|
-
headers[
|
36
|
-
|
37
|
-
if content_disposition
|
38
|
-
headers['Content-Disposition'] = content_disposition
|
39
|
-
end
|
65
|
+
headers["Content-Type"] = content_type
|
66
|
+
headers["Content-Disposition"] = content_disposition if content_disposition
|
40
67
|
|
41
|
-
|
42
|
-
|
68
|
+
begin
|
69
|
+
oss_upload_client.put_object(path, headers: headers) do |stream|
|
70
|
+
stream << file.read(CHUNK_SIZE) until file.eof?
|
71
|
+
end
|
43
72
|
path_to_url(path)
|
44
|
-
|
45
|
-
raise
|
73
|
+
rescue => e
|
74
|
+
raise "Put file failed: #{e}"
|
46
75
|
end
|
47
76
|
end
|
48
77
|
|
@@ -52,13 +81,15 @@ module CarrierWave
|
|
52
81
|
# returns:
|
53
82
|
# file data
|
54
83
|
def get(path)
|
55
|
-
path.sub
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
else
|
60
|
-
raise 'Get content faild'
|
84
|
+
path = path.sub(PATH_PREFIX, "")
|
85
|
+
chunk_buff = []
|
86
|
+
obj = oss_upload_client.get_object(path) do |chunk|
|
87
|
+
chunk_buff << chunk
|
61
88
|
end
|
89
|
+
|
90
|
+
[obj, chunk_buff.join("")]
|
91
|
+
rescue => e
|
92
|
+
raise "Get content faild: #{e}"
|
62
93
|
end
|
63
94
|
|
64
95
|
# 删除 Remote 的文件
|
@@ -69,80 +100,65 @@ module CarrierWave
|
|
69
100
|
# returns:
|
70
101
|
# 图片的下载地址
|
71
102
|
def delete(path)
|
72
|
-
path.sub
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
raise 'Delete failed'
|
78
|
-
end
|
103
|
+
path = path.sub(PATH_PREFIX, "")
|
104
|
+
oss_upload_client.delete_object(path)
|
105
|
+
path_to_url(path)
|
106
|
+
rescue => e
|
107
|
+
raise "Delete failed: #{e}"
|
79
108
|
end
|
80
109
|
|
81
110
|
##
|
82
111
|
# 根据配置返回完整的上传文件的访问地址
|
83
|
-
def path_to_url(path,
|
84
|
-
|
85
|
-
thumb_path = [path, opts[:thumb]].join('')
|
86
|
-
[@aliyun_host, thumb_path].join('/')
|
87
|
-
else
|
88
|
-
[@aliyun_host, path].join('/')
|
89
|
-
end
|
90
|
-
end
|
112
|
+
def path_to_url(path, thumb: nil)
|
113
|
+
path = path.sub(PATH_PREFIX, "")
|
91
114
|
|
92
|
-
|
93
|
-
|
94
|
-
def private_get_url(path, opts = {})
|
95
|
-
path.sub!(PATH_PREFIX, '')
|
96
|
-
url = ''
|
97
|
-
if opts[:thumb]
|
98
|
-
thumb_path = [path, opts[:thumb]].join('')
|
99
|
-
url = img_client.bucket_get_object_share_link(thumb_path, 3600)
|
115
|
+
if thumb
|
116
|
+
[self.host, [path, thumb].join("")].join("/")
|
100
117
|
else
|
101
|
-
|
118
|
+
[self.host, path].join("/")
|
102
119
|
end
|
103
|
-
url.gsub('http://', 'https://')
|
104
120
|
end
|
105
121
|
|
106
|
-
|
107
|
-
|
108
|
-
|
122
|
+
# 私有空间访问地址,会带上实时算出的 token 信息
|
123
|
+
# 有效期 15 minutes
|
124
|
+
def private_get_url(path, thumb: nil)
|
125
|
+
path = path.sub(PATH_PREFIX, "")
|
109
126
|
|
110
|
-
|
127
|
+
url = if thumb
|
128
|
+
img_client.object_url([path, thumb].join(""), expiry: 15.minutes)
|
129
|
+
else
|
130
|
+
oss_client.object_url(path, expiry: 15.minutes)
|
131
|
+
end
|
111
132
|
|
112
|
-
|
113
|
-
return @oss_client if defined?(@oss_client)
|
114
|
-
opts = {
|
115
|
-
host: "oss-#{@aliyun_area}.aliyuncs.com",
|
116
|
-
bucket: @aliyun_bucket
|
117
|
-
}
|
118
|
-
@oss_client = ::Aliyun::Oss::Client.new(@aliyun_access_id, @aliyun_access_key, opts)
|
133
|
+
url.sub("http://", "https://")
|
119
134
|
end
|
120
135
|
|
121
|
-
def
|
122
|
-
|
123
|
-
opts = {
|
124
|
-
host: "img-#{@aliyun_area}.aliyuncs.com",
|
125
|
-
bucket: @aliyun_bucket
|
126
|
-
}
|
127
|
-
@img_client = ::Aliyun::Oss::Client.new(@aliyun_access_id, @aliyun_access_key, opts)
|
136
|
+
def head(path)
|
137
|
+
oss_client.get_object_meta(path)
|
128
138
|
end
|
129
139
|
|
130
|
-
|
131
|
-
return @oss_upload_client if defined?(@oss_upload_client)
|
140
|
+
private
|
132
141
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
142
|
+
def oss_client
|
143
|
+
return @oss_client if defined?(@oss_client)
|
144
|
+
client = ::Aliyun::OSS::Client.new(endpoint: self.endpoint,
|
145
|
+
access_key_id: self.access_key_id, access_key_secret: self.access_key_secret)
|
146
|
+
@oss_client = client.get_bucket(self.bucket)
|
147
|
+
end
|
138
148
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
149
|
+
def img_client
|
150
|
+
return @img_client if defined?(@img_client)
|
151
|
+
client = ::Aliyun::OSS::Client.new(endpoint: self.img_endpoint,
|
152
|
+
access_key_id: self.access_key_id, access_key_secret: self.access_key_secret)
|
153
|
+
@img_client = client.get_bucket(self.bucket)
|
154
|
+
end
|
143
155
|
|
144
|
-
|
145
|
-
|
156
|
+
def oss_upload_client
|
157
|
+
return @oss_upload_client if defined?(@oss_upload_client)
|
158
|
+
client = ::Aliyun::OSS::Client.new(endpoint: self.upload_endpoint,
|
159
|
+
access_key_id: self.access_key_id, access_key_secret: self.access_key_secret)
|
160
|
+
@oss_upload_client = client.get_bucket(self.bucket)
|
161
|
+
end
|
146
162
|
end
|
147
163
|
end
|
148
164
|
end
|
@@ -1,19 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module CarrierWave
|
2
4
|
module Aliyun
|
3
5
|
module Configuration
|
4
6
|
extend ActiveSupport::Concern
|
5
7
|
|
6
8
|
included do
|
9
|
+
# Deprecation
|
7
10
|
add_config :aliyun_access_id
|
8
11
|
add_config :aliyun_access_key
|
9
|
-
add_config :aliyun_bucket
|
10
12
|
add_config :aliyun_area
|
13
|
+
add_config :aliyun_private_read
|
14
|
+
|
15
|
+
add_config :aliyun_access_key_id
|
16
|
+
add_config :aliyun_access_key_secret
|
17
|
+
add_config :aliyun_bucket
|
18
|
+
|
19
|
+
add_config :aliyun_region
|
11
20
|
add_config :aliyun_internal
|
12
21
|
add_config :aliyun_host
|
13
|
-
add_config :
|
22
|
+
add_config :aliyun_mode
|
14
23
|
|
15
24
|
configure do |config|
|
16
|
-
config.storage_engines[:aliyun] =
|
25
|
+
config.storage_engines[:aliyun] = "CarrierWave::Storage::Aliyun"
|
17
26
|
end
|
18
27
|
end
|
19
28
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module CarrierWave
|
2
4
|
module Storage
|
3
5
|
class AliyunFile < CarrierWave::SanitizedFile
|
@@ -10,9 +12,9 @@ module CarrierWave
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def read
|
13
|
-
|
14
|
-
@headers =
|
15
|
-
|
15
|
+
object, body = bucket.get(@path)
|
16
|
+
@headers = object.headers
|
17
|
+
body
|
16
18
|
end
|
17
19
|
|
18
20
|
def delete
|
@@ -30,7 +32,7 @@ module CarrierWave
|
|
30
32
|
# :thumb - Aliyun OSS Image Processor option, etc: @100w_200h_95q
|
31
33
|
#
|
32
34
|
def url(opts = {})
|
33
|
-
if
|
35
|
+
if bucket.mode == :private
|
34
36
|
bucket.private_get_url(@path, opts)
|
35
37
|
else
|
36
38
|
bucket.path_to_url(@path, opts)
|
@@ -38,7 +40,7 @@ module CarrierWave
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def content_type
|
41
|
-
headers[:content_type]
|
43
|
+
headers[:content_type]
|
42
44
|
end
|
43
45
|
|
44
46
|
def content_type=(new_content_type)
|
@@ -55,11 +57,11 @@ module CarrierWave
|
|
55
57
|
|
56
58
|
private
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
+
def bucket
|
61
|
+
return @bucket if defined? @bucket
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
+
@bucket = CarrierWave::Aliyun::Bucket.new(@uploader)
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-aliyun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -25,89 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.5.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: aliyun-
|
28
|
+
name: aliyun-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.6.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: sqlite3
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: activerecord
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: sqlite3-ruby
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: mini_magick
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rspec
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
40
|
+
version: 0.6.0
|
111
41
|
description: Aliyun OSS support for Carrierwave
|
112
42
|
email:
|
113
43
|
- huacnlee@gmail.com
|
@@ -143,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
73
|
version: '0'
|
144
74
|
requirements: []
|
145
75
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.7.9
|
147
77
|
signing_key:
|
148
78
|
specification_version: 4
|
149
79
|
summary: Aliyun OSS support for Carrierwave
|