bunny_cdn 1.1.1 → 1.3.1
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.
- checksums.yaml +4 -4
- data/README.md +24 -1
- data/bunny_cdn.gemspec +6 -6
- data/lib/bunny_cdn/storage.rb +32 -9
- data/lib/bunny_cdn/version.rb +1 -1
- metadata +18 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b9a5a9f040b398baf6c3bbbebec07479c2814b9d19afd0ea4a54925515be7f40
|
|
4
|
+
data.tar.gz: da187f28d3fac19b735995b0f9f74b82453995fceba6896cc2be1293644707e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15cd8d2c06247609032588ec640af54a07041b194212c486db5a58d2f802c4489f8c3adc19a0065053677b89026858c847a3a752f52ff20a8466687fd7e6a30b
|
|
7
|
+
data.tar.gz: 3dda63f9681deb5a5a4c9579112104a1495bf3569bf31364cf7d90b4bd2607d65f97da607c2365f4e076b2999966de67c8b9a80ef0cd42a933cff030d4f7d016
|
data/README.md
CHANGED
|
@@ -31,14 +31,37 @@ Or install it yourself as:
|
|
|
31
31
|
Create the initializer `config/initializers/bunny_cdn.rb` and set the configuration options.
|
|
32
32
|
|
|
33
33
|
```ruby
|
|
34
|
+
# Valid regions are:
|
|
35
|
+
# 'de' for Frankfurt, DE
|
|
36
|
+
# 'uk' for London, UK
|
|
37
|
+
# 'ny' for New York, US
|
|
38
|
+
# 'la' for Los Angeles, US
|
|
39
|
+
# 'sg' for Singapore, SG
|
|
40
|
+
# 'se' for Stockholm, SE
|
|
41
|
+
# 'br' for São Paulo, BR
|
|
42
|
+
# 'jh' for Johannesburg, SA
|
|
43
|
+
# 'syd' for Sydney, SYD
|
|
34
44
|
BunnyCdn.configure do |config|
|
|
35
45
|
config.apiKey = # The API key for your BunnyCDN account
|
|
36
46
|
config.storageZone = # The storage zone you want to work with
|
|
37
|
-
config.region = #
|
|
47
|
+
config.region = # The region of the storage zone.
|
|
38
48
|
config.accessKey = # The password for your storage zone
|
|
39
49
|
end
|
|
40
50
|
```
|
|
41
51
|
|
|
52
|
+
### File Uploads
|
|
53
|
+
|
|
54
|
+
New to v1.2.0, there are now two methods for handling file uploads.
|
|
55
|
+
|
|
56
|
+
To upload a file from a file input on a form, simply use
|
|
57
|
+
```ruby
|
|
58
|
+
BunnyCdn::Storage.uploadFormFile(path, file)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
To upload a file to BunnyCDN that already exists on the system, or to upload a file as a secondary option to storing it on the system use
|
|
62
|
+
```ruby
|
|
63
|
+
BunnyCdn::Storage.uploadFile(path, file)
|
|
64
|
+
```
|
|
42
65
|
## Development
|
|
43
66
|
|
|
44
67
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/bunny_cdn.gemspec
CHANGED
|
@@ -29,12 +29,12 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
spec.require_paths = ["lib"]
|
|
30
30
|
|
|
31
31
|
spec.add_dependency 'rest-client', '~> 2.1'
|
|
32
|
-
spec.add_dependency 'json', '~> 2.
|
|
32
|
+
spec.add_dependency 'json', '~> 2.12'
|
|
33
33
|
|
|
34
|
-
spec.add_development_dependency "bundler",
|
|
35
|
-
spec.add_development_dependency "rake",
|
|
36
|
-
spec.add_development_dependency "rspec",
|
|
37
|
-
spec.add_development_dependency "webmock", '~> 3.
|
|
34
|
+
spec.add_development_dependency "bundler", '~> 2.6.9'
|
|
35
|
+
spec.add_development_dependency "rake", '~> 13.2', '>= 13.2.1'
|
|
36
|
+
spec.add_development_dependency "rspec", '~> 3.13'
|
|
37
|
+
spec.add_development_dependency "webmock", '~> 3.25', '>= 3.25.1'
|
|
38
38
|
|
|
39
|
-
spec.required_ruby_version = '>=
|
|
39
|
+
spec.required_ruby_version = '>= 3.0.0'
|
|
40
40
|
end
|
data/lib/bunny_cdn/storage.rb
CHANGED
|
@@ -10,15 +10,20 @@ module BunnyCdn
|
|
|
10
10
|
|
|
11
11
|
# Sets the proper URL based on the region set in configuration
|
|
12
12
|
def self.set_region_url
|
|
13
|
-
case BunnyCdn.configuration.region
|
|
14
|
-
when nil || 'eu'
|
|
13
|
+
# case BunnyCdn.configuration.region
|
|
14
|
+
# when nil || 'eu'
|
|
15
|
+
# 'https://storage.bunnycdn.com'
|
|
16
|
+
# when 'ny'
|
|
17
|
+
# 'https://ny.storage.bunnycdn.com'
|
|
18
|
+
# when 'la'
|
|
19
|
+
# 'https://la.storage.bunnycdn.com'
|
|
20
|
+
# when 'sg'
|
|
21
|
+
# 'https://sg.storage.bunnycdn.com'
|
|
22
|
+
# end
|
|
23
|
+
if BunnyCdn.configuration.region.nil? || BunnyCdn.configuration.region == 'de'
|
|
15
24
|
'https://storage.bunnycdn.com'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
when 'la'
|
|
19
|
-
'https://la.storage.bunnycdn.com'
|
|
20
|
-
when 'sg'
|
|
21
|
-
'https://sg.storage.bunnycdn.com'
|
|
25
|
+
else
|
|
26
|
+
"https://#{BunnyCdn.configuration.region}.storage.bunnycdn.com"
|
|
22
27
|
end
|
|
23
28
|
end
|
|
24
29
|
|
|
@@ -59,7 +64,7 @@ module BunnyCdn
|
|
|
59
64
|
return response.body
|
|
60
65
|
end
|
|
61
66
|
|
|
62
|
-
# Uploads a file to the storage zone
|
|
67
|
+
# Uploads a file on the system to the storage zone
|
|
63
68
|
# Params:
|
|
64
69
|
# +path+:: desired path to upload file
|
|
65
70
|
# +file+:: specific file to upload to storage zone
|
|
@@ -77,6 +82,24 @@ module BunnyCdn
|
|
|
77
82
|
return response.body
|
|
78
83
|
end
|
|
79
84
|
|
|
85
|
+
# Uploads a file from a file input to the storage zone
|
|
86
|
+
# Params:
|
|
87
|
+
# +path+:: desired path to upload file
|
|
88
|
+
# +file+:: specific file to upload to storage zone
|
|
89
|
+
def self.uploadFormFile(path= '', file)
|
|
90
|
+
fileName = file.original_filename
|
|
91
|
+
headers = {
|
|
92
|
+
:accessKey => apiKey,
|
|
93
|
+
:checksum => ''
|
|
94
|
+
}
|
|
95
|
+
begin
|
|
96
|
+
response = RestClient.put("#{set_region_url}/#{storageZone}/#{path}/#{fileName}", File.read(file.tempfile), headers)
|
|
97
|
+
rescue RestClient::ExceptionWithResponse => exception
|
|
98
|
+
return exception
|
|
99
|
+
end
|
|
100
|
+
return response.body
|
|
101
|
+
end
|
|
102
|
+
|
|
80
103
|
# Deletes a file from the storage zone
|
|
81
104
|
# Params:
|
|
82
105
|
# +path+:: path to delete file from
|
data/lib/bunny_cdn/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bunny_cdn
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brandon Meeks
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rest-client
|
|
@@ -30,82 +29,82 @@ dependencies:
|
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '2.
|
|
32
|
+
version: '2.12'
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '2.
|
|
39
|
+
version: '2.12'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: bundler
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
46
|
+
version: 2.6.9
|
|
48
47
|
type: :development
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
51
|
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
53
|
+
version: 2.6.9
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
55
|
name: rake
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
58
|
- - "~>"
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
60
|
+
version: '13.2'
|
|
62
61
|
- - ">="
|
|
63
62
|
- !ruby/object:Gem::Version
|
|
64
|
-
version:
|
|
63
|
+
version: 13.2.1
|
|
65
64
|
type: :development
|
|
66
65
|
prerelease: false
|
|
67
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
68
67
|
requirements:
|
|
69
68
|
- - "~>"
|
|
70
69
|
- !ruby/object:Gem::Version
|
|
71
|
-
version: '
|
|
70
|
+
version: '13.2'
|
|
72
71
|
- - ">="
|
|
73
72
|
- !ruby/object:Gem::Version
|
|
74
|
-
version:
|
|
73
|
+
version: 13.2.1
|
|
75
74
|
- !ruby/object:Gem::Dependency
|
|
76
75
|
name: rspec
|
|
77
76
|
requirement: !ruby/object:Gem::Requirement
|
|
78
77
|
requirements:
|
|
79
78
|
- - "~>"
|
|
80
79
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '3.
|
|
80
|
+
version: '3.13'
|
|
82
81
|
type: :development
|
|
83
82
|
prerelease: false
|
|
84
83
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
84
|
requirements:
|
|
86
85
|
- - "~>"
|
|
87
86
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '3.
|
|
87
|
+
version: '3.13'
|
|
89
88
|
- !ruby/object:Gem::Dependency
|
|
90
89
|
name: webmock
|
|
91
90
|
requirement: !ruby/object:Gem::Requirement
|
|
92
91
|
requirements:
|
|
93
92
|
- - "~>"
|
|
94
93
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '3.
|
|
94
|
+
version: '3.25'
|
|
96
95
|
- - ">="
|
|
97
96
|
- !ruby/object:Gem::Version
|
|
98
|
-
version: 3.
|
|
97
|
+
version: 3.25.1
|
|
99
98
|
type: :development
|
|
100
99
|
prerelease: false
|
|
101
100
|
version_requirements: !ruby/object:Gem::Requirement
|
|
102
101
|
requirements:
|
|
103
102
|
- - "~>"
|
|
104
103
|
- !ruby/object:Gem::Version
|
|
105
|
-
version: '3.
|
|
104
|
+
version: '3.25'
|
|
106
105
|
- - ">="
|
|
107
106
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: 3.
|
|
107
|
+
version: 3.25.1
|
|
109
108
|
description: This is a simple gem to help you work with BunnyCDN.
|
|
110
109
|
email: meeksb86@gmail.com
|
|
111
110
|
executables: []
|
|
@@ -135,7 +134,6 @@ metadata:
|
|
|
135
134
|
homepage_uri: https://github.com/brandon-meeks/bunny_cdn_gem
|
|
136
135
|
source_code_uri: https://github.com/brandon-meeks/bunny_cdn_gem
|
|
137
136
|
changelog_uri: https://github.com/brandon-meeks/bunny_cdn/releases
|
|
138
|
-
post_install_message:
|
|
139
137
|
rdoc_options: []
|
|
140
138
|
require_paths:
|
|
141
139
|
- lib
|
|
@@ -143,15 +141,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
143
141
|
requirements:
|
|
144
142
|
- - ">="
|
|
145
143
|
- !ruby/object:Gem::Version
|
|
146
|
-
version:
|
|
144
|
+
version: 3.0.0
|
|
147
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
146
|
requirements:
|
|
149
147
|
- - ">="
|
|
150
148
|
- !ruby/object:Gem::Version
|
|
151
149
|
version: '0'
|
|
152
150
|
requirements: []
|
|
153
|
-
rubygems_version: 3.
|
|
154
|
-
signing_key:
|
|
151
|
+
rubygems_version: 3.6.9
|
|
155
152
|
specification_version: 4
|
|
156
153
|
summary: Gem to work with BunnyCDN
|
|
157
154
|
test_files: []
|