activestorage-aliyun 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 796ec942f06897cf76873d1b6dadeb23a565345f
4
- data.tar.gz: fd06616edba762ac6ccf4e352cbec7a17fc220dd
2
+ SHA256:
3
+ metadata.gz: 7a6e97cb757b635493a02597209f20c7b73283f6922b604fac48836cb86c323f
4
+ data.tar.gz: c3472d980a98774ce2e4592c68cef5fd36b88423243fc1c9a5fa0b76f39518e4
5
5
  SHA512:
6
- metadata.gz: 91698652328b356a3df0c7fbd1fa45a4f5e7185df39d097d19402fdf77e3eaad9190af997c4b21ed89dac385e87c9cebf27ef6303ca222a912291c8feec77f1b
7
- data.tar.gz: d935a34961783cd60f41055480557a14017a01b3db3b60194c39a2801f8907c38ed403cb578b6244803070e30f1c037cbbc85d8330421ea61bff2e40049aff69
6
+ metadata.gz: 6f1c434607f6db1ae7383143b9ac4d8673b8b39af86c1ae130c9617bb1d23fc81ca9cb458d25b7b432f5199ee4856a9741ae84f229d7669ef4408c32218ff0b3
7
+ data.tar.gz: 2a748673e30e2d73cc4b335c017265592ccfca051f3bf4ae775a72731549dfc376aeaca94dd35866cf15bc58d48d994fa54782ead184dcfe19760cff28be91a8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.4.0
2
+
3
+ - Support present `params` to `service_url` to oss image url.
4
+
5
+ for example:
6
+
7
+ ```rb
8
+ @photo.image.service_url(params: { 'x-oss-process' => "image/resize,h_100,w_100" })
9
+ ```
10
+
1
11
  ## 0.3.0
2
12
 
3
13
  - Add `mode` config for setup OSS ACL, `mode: "private"` will always output URL that have signature info.
data/README.md CHANGED
@@ -43,10 +43,22 @@ production:
43
43
  Orignial File URL:
44
44
 
45
45
  <%= image_tag @photo.image.service_url %>
46
+ ```
46
47
 
47
48
  Thumb with OSS image service:
48
49
 
49
- <%= image_tag @photo.image.service_url(filename: 'x-oss-process=image/resize,h_100,w_100') %>
50
+ ```rb
51
+ class Photo < ApplicationRecord
52
+ def image_thumb_url(process)
53
+ self.image.service_url(params: { "x-oss-process" => process })
54
+ end
55
+ end
56
+ ```
57
+
58
+ And then:
59
+
60
+ ```erb
61
+ <%= image_tag @photo.image.image_thumb_url("image/resize,h_100,w_100") %>
50
62
  ```
51
63
 
52
64
  ### Use for file download
@@ -52,19 +52,18 @@ module ActiveStorage
52
52
  end
53
53
  end
54
54
 
55
- def url(key, expires_in:, filename:, content_type:, disposition:)
55
+ def url(key, expires_in:, filename: nil, content_type:, disposition:, params: {})
56
56
  instrument :url, key: key do |payload|
57
57
  sign = private_mode? || disposition == :attachment
58
58
  filekey = path_for(key)
59
- params = {}
60
59
 
61
60
  if disposition == :attachment
62
61
  params["response-content-type"] = content_type if content_type
63
- params["response-content-disposition"] = "attachment;filename*=UTF-8''#{CGI.escape(filename.to_s)}"
64
- else
65
- if filename.to_s.include?("x-oss-process")
66
- params["x-oss-process"] = filename.to_s.split("=").last
62
+ unless filename.is_a?(ActiveStorage::Filename)
63
+ filename = ActiveStorage::Filename.new(filename)
67
64
  end
65
+
66
+ params["response-content-disposition"] = content_disposition_with(type: disposition, filename: filename)
68
67
  end
69
68
 
70
69
  generated_url = object_url(filekey, sign: sign, expires_in: expires_in, params: params)
@@ -1,3 +1,3 @@
1
1
  module ActiveStorageAliyun
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage-aliyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0.rc
19
+ version: 5.2.0.rc2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.0.rc
26
+ version: 5.2.0.rc2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: aliyun-sdk
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  version: '0'
72
72
  requirements: []
73
73
  rubyforge_project:
74
- rubygems_version: 2.6.13
74
+ rubygems_version: 2.7.6
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Wraps the Aliyun OSS as an Active Storage service