aliyun-oss-sdk 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -0
  3. data/Gemfile +1 -0
  4. data/README.md +12 -10
  5. data/Rakefile +10 -0
  6. data/aliyun-oss.gemspec +2 -2
  7. data/lib/aliyun/oss.rb +4 -11
  8. data/lib/aliyun/oss/authorization.rb +59 -27
  9. data/lib/aliyun/oss/client.rb +137 -62
  10. data/lib/aliyun/oss/client/bucket_multiparts.rb +43 -0
  11. data/lib/aliyun/oss/client/bucket_objects.rb +111 -0
  12. data/lib/aliyun/oss/client/buckets.rb +50 -0
  13. data/lib/aliyun/oss/client/clients.rb +54 -0
  14. data/lib/aliyun/oss/error.rb +43 -0
  15. data/lib/aliyun/oss/http.rb +65 -23
  16. data/lib/aliyun/oss/struct.rb +26 -0
  17. data/lib/aliyun/oss/struct/bucket.rb +252 -0
  18. data/lib/aliyun/oss/struct/cors.rb +65 -0
  19. data/lib/aliyun/oss/struct/lifecycle.rb +73 -0
  20. data/lib/aliyun/oss/struct/logging.rb +33 -0
  21. data/lib/aliyun/oss/struct/multipart.rb +101 -0
  22. data/lib/aliyun/oss/struct/object.rb +71 -0
  23. data/lib/aliyun/oss/struct/part.rb +48 -0
  24. data/lib/aliyun/oss/struct/referer.rb +21 -0
  25. data/lib/aliyun/oss/struct/website.rb +13 -0
  26. data/lib/aliyun/oss/utils.rb +41 -1
  27. data/lib/aliyun/oss/version.rb +1 -1
  28. data/lib/aliyun/oss/xml_generator.rb +174 -0
  29. data/todo.md +5 -0
  30. data/wiki/bucket.md +20 -20
  31. data/wiki/cors.md +59 -0
  32. data/wiki/error.md +42 -31
  33. data/wiki/get_start.md +24 -7
  34. data/wiki/installation.md +2 -2
  35. data/wiki/lifecycle.md +75 -0
  36. data/wiki/multipart.md +7 -5
  37. data/wiki/object.md +16 -12
  38. metadata +48 -6
  39. data/lib/aliyun/oss/multipart/part.rb +0 -32
  40. data/lib/aliyun/oss/rule/cors.rb +0 -63
  41. data/lib/aliyun/oss/rule/lifecycle.rb +0 -61
@@ -1,32 +0,0 @@
1
- module Aliyun
2
- module Oss
3
- module Multipart
4
- class Part
5
- # [Integer] :number the part number
6
- attr_accessor :number
7
-
8
- # [String] :etag the etag for the part
9
- attr_accessor :etag
10
-
11
- def initialize(options = {})
12
- @number = options[:number]
13
- @etag = options[:etag]
14
- end
15
-
16
- def to_hash
17
- if valid?
18
- { 'PartNumber' => number, 'ETag' => etag }
19
- else
20
- {}
21
- end
22
- end
23
-
24
- private
25
-
26
- def valid?
27
- number && etag
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,63 +0,0 @@
1
- module Aliyun
2
- module Oss
3
- module Rule
4
- class Cors
5
- ACCESSPTED_METHODS = %w(GET PUT DELETE POST HEAD)
6
-
7
- # [Array] :allowed_origins Set allowed origins
8
- attr_accessor :allowed_origins
9
-
10
- # [Array] :allowed_methods Set allowed methods
11
- attr_accessor :allowed_methods
12
-
13
- # [Array] :allowed_headers Set allowed headers used in preflight (see #bucket_preflight)
14
- attr_accessor :allowed_headers
15
-
16
- # [Array] :expose_headers Set allowed used response headers for user
17
- attr_accessor :expose_headers
18
-
19
- # [Integer] :max_age_seconds Specifies cache time the browser to pre-fetch a particular resource request in seconds
20
- attr_accessor :max_age_seconds
21
-
22
- def initialize(options = {})
23
- @allowed_origins = options[:allowed_origins]
24
- @allowed_methods = options[:allowed_methods]
25
- @allowed_headers = options[:allowed_headers]
26
- @expose_headers = options[:expose_headers]
27
- @max_age_seconds = options[:max_age_seconds]
28
- end
29
-
30
- def to_hash
31
- if valid?
32
- hash = {
33
- 'AllowedOrigin' => allowed_origins,
34
- 'AllowedMethod' => allowed_methods
35
- }
36
- hash.merge!('AllowedHeader' => allowed_headers) if value_present?(allowed_headers)
37
- hash.merge!('EsposeHeader' => expose_headers) if value_present?(expose_headers)
38
- hash.merge!('MaxAgeSeconds' => max_age_seconds) if max_age_seconds
39
- hash
40
- else
41
- {}
42
- end
43
- end
44
-
45
- private
46
-
47
- def valid?
48
- value_present?(allowed_origins) && value_present?(allowed_methods)
49
- end
50
-
51
- def allowed_methods
52
- @allowed_methods
53
- .map(&:upcase)
54
- .select { |method| ACCESSPTED_METHODS.include?(method.to_s) }
55
- end
56
-
57
- def value_present?(value)
58
- value && !value.empty?
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,61 +0,0 @@
1
- module Aliyun
2
- module Oss
3
- module Rule
4
- class LifeCycle
5
- # [Integer] optional, Rule ID, auto set when not set
6
- attr_accessor :id
7
-
8
- # [String] Used for filter objects
9
- attr_accessor :prefix
10
-
11
- # [Boolean] Used for set rule status
12
- attr_accessor :enable
13
-
14
- # [Integer] Set auto delete objects after days since last modified, at least exist one with date
15
- attr_accessor :days
16
-
17
- # [Time] Set auto auto delete object at given time, at least exist one with days
18
- attr_accessor :date
19
-
20
- def initialize(options = {})
21
- @id = options[:id]
22
- @prefix = options[:prefix]
23
- @enable = options[:enable]
24
- @days = options[:days]
25
- @date = options[:date]
26
- end
27
-
28
- def to_hash
29
- if valid?
30
- {
31
- 'ID' => id || '',
32
- 'Prefix' => prefix,
33
- 'Status' => status,
34
- 'Expiration' => expiration
35
- }
36
- else
37
- {}
38
- end
39
- end
40
-
41
- private
42
-
43
- def valid?
44
- prefix && (days || date)
45
- end
46
-
47
- def status
48
- enable ? 'Enabled' : 'Disabled'
49
- end
50
-
51
- def expiration
52
- if date && date.is_a?(Time)
53
- { 'Date' => date.utc.strftime('%Y-%m-%dT00:00:00.000Z') }
54
- elsif days && days.is_a?(Integer)
55
- { 'Days' => days.to_i }
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end