faster_s3_url 0.1.0 → 0.2.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
2
  SHA256:
3
- metadata.gz: 8def7b598503ea770dec6923c611bb3b5fa506ba90f89852ce299457ccbefb1e
4
- data.tar.gz: 79161290e666ca39b0a9f349dc69fcb326edbeb3b975c8c0ede9c0d97c892737
3
+ metadata.gz: a4d2733027591b130ee900af58e9e3327be81f2f77204d74c2adf43f6daeae0a
4
+ data.tar.gz: c7666c94d5e4f6dd4113c64ecab0f18f4a26bcd86b53679a071a0a3158602499
5
5
  SHA512:
6
- metadata.gz: 62f80a646516296746d851bcdf870c4c0e06a48af6d9e677a53c391b93ec6e4fd14dc86be73f2f540d1ce71587fc3fe2fc4abf19c6b8917e63fa75001e62a261
7
- data.tar.gz: c3d738c8c3811954540725227a042da8820b9dd0a670e2aa32098c3be5cf015745d5217c904f9f6b0f6f762469f1147db0a76c8f9644d4c29ed8a0ff9d5f4559
6
+ metadata.gz: 3da1e5c8137b65d6fee213ce076aded9141bbe098c342b0b1dd3e3275003b5f9e5ba9d649951273923430babcc0033344200676825ba631cefe97646ea43435c
7
+ data.tar.gz: 1c84a1928bc44a3d70c089c93d1f399c2a150e79c61c10345081d2fe84616c7882cb532803549e17b17f6e41698c5ee71e59dfef5af81cca821fe294575f7ccf
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Generate public and presigned AWS S3 `GET` URLs faster in ruby
4
4
 
5
- [![Build Status](https://travis-ci.com/jrochkind/faster_s3_url.svg?branch=master)](https://travis-ci.com/jrochkind/faster_s3_url)
5
+ [![Gem Version](https://badge.fury.io/rb/faster_s3_url.svg)](https://badge.fury.io/rb/faster_s3_url) [![Build Status](https://travis-ci.com/jrochkind/faster_s3_url.svg?branch=master)](https://travis-ci.com/jrochkind/faster_s3_url)
6
6
 
7
7
  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
8
 
@@ -19,8 +19,12 @@ signer = FasterS3Url::Builder.new(
19
19
  )
20
20
 
21
21
  signer.public_url("my/object/key.jpg")
22
- #=> "https://my-bucket.aws"
22
+ #=> "https://my-bucket.s3.amazonaws.com/my/object/key.jpg"
23
+ # does handle URI-escaping keys properly
24
+
23
25
  signer.presigned_url("my/object/key.jpg")
26
+ # => https://my-bucket.s3.amazonaws.com/my/object/key.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=fakeExampleAccessKeyId%2F20201001%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201001T183223Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=b5d2ec17cd7c9d4cc45f446f87b17522f18d3776f06d051bef73fb8329a2e605
27
+ # Also can handle additional query params such as response_content_disposition
24
28
  ```
25
29
 
26
30
  You can re-use a signer object for convenience or slighlty improved performance. It should be concurrency-safe to share globally between threads.
@@ -30,7 +34,7 @@ If you are using S3 keys that need to be escaped in the URLs, this gem will escp
30
34
  When presigning URLs, you can pass the query parameters supported by S3 to control subsequent response headers. You can also supply a version_id for a URL to access a specific version.
31
35
 
32
36
  ```ruby
33
- signer.presigned_url("my/object/key.jpg"
37
+ signer.presigned_url("my/object/key.jpg",
34
38
  response_cache_control: "public, max-age=604800, immutable",
35
39
  response_content_disposition: "attachment",
36
40
  response_content_language: "de-DE, en-CA",
@@ -122,7 +126,7 @@ A couple minor differences, let me know if they disrupt you:
122
126
 
123
127
  ## Performance Benchmarking
124
128
 
125
- Benchmarks were done using scripts checked into repo at `./perf` (which use benchmark-ips with mode `:stats => :bootstrap, :confidence => 95`), on my 2015 Macbook Pro, using ruby MRI 2.6.6. Benchmarking is never an exact science, hopefully this is reasonable.
129
+ Benchmarks were done using scripts checked into repo at `./perf` (which use benchmark-ips with mode `:stats => :bootstrap, :confidence => 95`), on my 2015 Macbook Pro, using ruby MRI 2.6.6., on faster_s3_url version 0.1.0. Benchmarking is never an exact science, hopefully this is reasonable.
126
130
 
127
131
  In my narrative, I normalize to how many iterations can happen in **10ms** to have numbers closer to what might be typical use cases.
128
132
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'cgi'
4
+
3
5
  module FasterS3Url
4
6
  # Signing algorithm based on Amazon docs at https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html ,
5
7
  # as well as some interactive code reading of Aws::Sigv4::Signer
@@ -23,6 +23,9 @@ module FasterS3Url
23
23
  # * We support a `host` option on initializer, but do NOT support the `host` option on #url (I don't underestand
24
24
  # why it's per-call in the first place, do you need it to be?)
25
25
  #
26
+ # * You DO need to supply access_key_id and secret_access_key in initializer, they can not be automatically
27
+ # looked up from AWS environmental chain. See README.
28
+ #
26
29
  class Storage < ::Shrine::Storage::S3
27
30
  # Same options as Shrine::Storage::S3, plus `host`
28
31
  def initialize(**options)
@@ -1,3 +1,3 @@
1
1
  module FasterS3Url
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-01 00:00:00.000000000 Z
11
+ date: 2020-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
- description:
83
+ description:
84
84
  email:
85
85
  - jrochkind@sciencehistory.org
86
86
  executables: []
@@ -110,7 +110,7 @@ licenses:
110
110
  metadata:
111
111
  homepage_uri: https://github.com/jrochkind/faster_s3_url
112
112
  source_code_uri: https://github.com/jrochkind/faster_s3_url
113
- post_install_message:
113
+ post_install_message:
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubygems_version: 3.0.3
129
- signing_key:
129
+ signing_key:
130
130
  specification_version: 4
131
131
  summary: Generate public and presigned AWS S3 GET URLs faster
132
132
  test_files: []