faster_s3_url 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +25 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +3 -2
- data/README.md +2 -1
- data/faster_s3_url.gemspec +1 -0
- data/lib/faster_s3_url/builder.rb +21 -12
- data/lib/faster_s3_url/shrine/storage.rb +3 -1
- data/lib/faster_s3_url/version.rb +1 -1
- metadata +19 -4
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19961406eae206e2857fd3f33d6a9f2d17a2f87974accd449db44f00a5d086fd
|
4
|
+
data.tar.gz: 8e490830bd078b73eddfc00eee1f0cc847432bab536cee1a4e5eb2635666cc4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40b65520c01ae860dea80dba4a25c7817d9a8978c1cbc7bc538d7b0ed92e5c898597340f0c93141355929af98bb7aa7656c95469c758348744ddd77b6666b9ec
|
7
|
+
data.tar.gz: 12d30342cb72e806e6c11e9c0e27b078cd0e1dfa419303437724d76acb698b30ec1b500bde020dd513802d65097ddc7f2997b9e9cfb59bd669f5e6bb085e9fb9
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: ['**']
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
tests:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 2.6.6
|
20
|
+
|
21
|
+
- name: Bundle install
|
22
|
+
run: bundle install --jobs 4 --retry 3
|
23
|
+
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rake
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## 1.1.0
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- response-expires header format match recent AWS ruby SDK by using #httpdate https://github.com/jrochkind/faster_s3_url/pull/5
|
13
|
+
|
14
|
+
- Only define local Storage#object_key if Shrine isn't already providing https://github.com/jrochkind/faster_s3_url/pull/7
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- Some decrease in memory allocations made by gem https://github.com/jrochkind/faster_s3_url/pull/6
|
data/Gemfile
CHANGED
@@ -7,5 +7,6 @@ gem "rake", "~> 12.0"
|
|
7
7
|
gem "rspec", "~> 3.0"
|
8
8
|
|
9
9
|
gem 'pry-byebug', "~> 3.9"
|
10
|
-
#
|
11
|
-
|
10
|
+
# used by benchmark-ips in our perf/ profiling scripts.
|
11
|
+
# https://github.com/evanphx/benchmark-ips#advanced-statistics
|
12
|
+
gem 'kalibera'
|
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
Generate public and presigned AWS S3 `GET` URLs faster in ruby
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/faster_s3_url.svg)](https://badge.fury.io/rb/faster_s3_url) [![
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/faster_s3_url.svg)](https://badge.fury.io/rb/faster_s3_url) [![CI Status](https://github.com/jrochkind/faster_s3_url/workflows/CI/badge.svg?branch=master)](https://github.com/jrochkind/faster_s3_url/actions?query=workflow%3ACI+branch%3Amaster)
|
6
|
+
|
6
7
|
|
7
8
|
The official [ruby AWS SDK](https://github.com/aws/aws-sdk-ruby) is actually quite slow and unoptimized when generating URLs to access S3 objects. If you are only creating a couple S3 URLs at a time this may not matter. But it can matter on the order of even two or three hundred at a time, especially when creating presigned URLs, for which the AWS SDK is especially un-optimized.
|
8
9
|
|
data/faster_s3_url.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
29
|
spec.add_development_dependency "aws-sdk-s3", "~> 1.81"
|
30
|
+
spec.add_development_dependency "nokogiri" # aws gem now has implicit dependency on an XML processor such as
|
30
31
|
spec.add_development_dependency "timecop", "< 2"
|
31
32
|
spec.add_development_dependency "benchmark-ips", "~> 2.8"
|
32
33
|
#spec.add_development_dependency "kalibera" # for benchmark-ips :bootstrap stats option
|
@@ -206,7 +206,6 @@ module FasterS3Url
|
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
209
|
-
|
210
209
|
# Becaues CGI.escape in MRI is written in C, this really does seem
|
211
210
|
# to be the fastest way to get the semantics we want, starting with
|
212
211
|
# CGI.escape and doing extra gsubs. Alternative would be using something
|
@@ -215,7 +214,12 @@ module FasterS3Url
|
|
215
214
|
if string.nil?
|
216
215
|
nil
|
217
216
|
else
|
218
|
-
CGI.escape(string.encode('UTF-8')).
|
217
|
+
CGI.escape(string.encode('UTF-8')).tap do |s|
|
218
|
+
# there is a clever way to do this in one gsub, but doesn't necessarily help
|
219
|
+
# memory allocations or performance
|
220
|
+
s.gsub!('+'.freeze, '%20'.freeze)
|
221
|
+
s.gsub!('%7E'.freeze, '~'.freeze)
|
222
|
+
end
|
219
223
|
end
|
220
224
|
end
|
221
225
|
|
@@ -228,7 +232,13 @@ module FasterS3Url
|
|
228
232
|
if string.nil?
|
229
233
|
nil
|
230
234
|
else
|
231
|
-
CGI.escape(string.encode('UTF-8')).
|
235
|
+
CGI.escape(string.encode('UTF-8')).tap do |s|
|
236
|
+
# there is a clever way to do this in one gsub, but doesn't necessarily help
|
237
|
+
# memory allocations or performance
|
238
|
+
s.gsub!('+'.freeze, '%20'.freeze)
|
239
|
+
s.gsub!('%7E'.freeze, '~'.freeze)
|
240
|
+
s.gsub!('%2F'.freeze, '/'.freeze)
|
241
|
+
end
|
232
242
|
end
|
233
243
|
end
|
234
244
|
|
@@ -256,7 +266,7 @@ module FasterS3Url
|
|
256
266
|
|
257
267
|
def validate_expires_in(expires_in)
|
258
268
|
if expires_in > ONE_WEEK
|
259
|
-
raise ArgumentError.new("expires_in value of #{expires_in} exceeds one-week maximum.")
|
269
|
+
raise ArgumentError.new("expires_in value of #{expires_in} exceeds one-week (#{ONE_WEEK}) maximum.")
|
260
270
|
elsif expires_in <= 0
|
261
271
|
raise ArgumentError.new("expires_in value of #{expires_in} cannot be 0 or less.")
|
262
272
|
end
|
@@ -265,14 +275,13 @@ module FasterS3Url
|
|
265
275
|
# Crazy kind of reverse engineered from aws-sdk-ruby,
|
266
276
|
# for compatible handling of Expires header.
|
267
277
|
#
|
268
|
-
#
|
269
|
-
# an
|
270
|
-
#
|
271
|
-
#
|
272
|
-
# with aws-sdk-s3: https://github.com/aws/aws-sdk-ruby/issues/2415
|
278
|
+
# Recent versions of ruby AWS SDK use "httpdate" format here, as a result of
|
279
|
+
# an issue we filed: https://github.com/aws/aws-sdk-ruby/issues/2415
|
280
|
+
#
|
281
|
+
# We match what recent AWS SDK does.
|
273
282
|
#
|
274
|
-
#
|
275
|
-
#
|
283
|
+
# Note while the AWS SDK source says "rfc 822", it's ruby #httpdate that matches
|
284
|
+
# rather than ruby #rfc822 (timezone should be `GMT` to match AWS SDK, not `-0000`)
|
276
285
|
def convert_for_timestamp_shape(arg)
|
277
286
|
return nil if arg.nil?
|
278
287
|
|
@@ -286,7 +295,7 @@ module FasterS3Url
|
|
286
295
|
else
|
287
296
|
Time.parse(arg.to_s)
|
288
297
|
end
|
289
|
-
time_value.utc.
|
298
|
+
time_value.utc.httpdate
|
290
299
|
end
|
291
300
|
end
|
292
301
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
gem "shrine", "~> 3.0"
|
2
4
|
require 'shrine/storage/s3'
|
3
5
|
|
@@ -59,7 +61,7 @@ module FasterS3Url
|
|
59
61
|
end
|
60
62
|
|
61
63
|
# For older shrine versions without it, we need this...
|
62
|
-
unless self.method_defined?(:object_key)
|
64
|
+
unless self.method_defined?(:object_key) || self.private_method_defined?(:object_key)
|
63
65
|
def object_key(id)
|
64
66
|
[*prefix, id].join("/")
|
65
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faster_s3_url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.81'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: timecop
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,9 +101,10 @@ executables: []
|
|
87
101
|
extensions: []
|
88
102
|
extra_rdoc_files: []
|
89
103
|
files:
|
104
|
+
- ".github/workflows/ci.yml"
|
90
105
|
- ".gitignore"
|
91
106
|
- ".rspec"
|
92
|
-
-
|
107
|
+
- CHANGELOG.md
|
93
108
|
- Gemfile
|
94
109
|
- LICENSE.txt
|
95
110
|
- README.md
|
@@ -125,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
140
|
- !ruby/object:Gem::Version
|
126
141
|
version: '0'
|
127
142
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.4.21
|
129
144
|
signing_key:
|
130
145
|
specification_version: 4
|
131
146
|
summary: Generate public and presigned AWS S3 GET URLs faster
|