shrine 2.14.0 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of shrine might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +384 -374
- data/README.md +132 -63
- data/doc/advantages.md +191 -109
- data/doc/attacher.md +1 -1
- data/doc/carrierwave.md +4 -4
- data/doc/creating_storages.md +2 -2
- data/doc/design.md +2 -2
- data/doc/direct_s3.md +3 -3
- data/doc/metadata.md +1 -1
- data/doc/multiple_files.md +2 -2
- data/doc/paperclip.md +3 -3
- data/doc/plugins/activerecord.md +92 -0
- data/doc/plugins/add_metadata.md +93 -0
- data/doc/plugins/backgrounding.md +148 -0
- data/doc/plugins/backup.md +29 -0
- data/doc/plugins/cached_attachment_data.md +23 -0
- data/doc/plugins/copy.md +22 -0
- data/doc/plugins/data_uri.md +92 -0
- data/doc/plugins/default_storage.md +16 -0
- data/doc/plugins/default_url.md +33 -0
- data/doc/plugins/default_url_options.md +22 -0
- data/doc/plugins/delete_promoted.md +10 -0
- data/doc/plugins/delete_raw.md +16 -0
- data/doc/plugins/derivation_endpoint.md +747 -0
- data/doc/plugins/determine_mime_type.md +64 -0
- data/doc/plugins/direct_upload.md +170 -0
- data/doc/plugins/download_endpoint.md +83 -0
- data/doc/plugins/dynamic_storage.md +20 -0
- data/doc/plugins/hooks.md +56 -0
- data/doc/plugins/included.md +15 -0
- data/doc/plugins/infer_extension.md +57 -0
- data/doc/plugins/keep_files.md +20 -0
- data/doc/plugins/logging.md +39 -0
- data/doc/plugins/metadata_attribues.md +43 -0
- data/doc/plugins/migration_helpers.md +58 -0
- data/doc/plugins/module_include.md +40 -0
- data/doc/plugins/moving.md +17 -0
- data/doc/plugins/multi_delete.md +18 -0
- data/doc/plugins/parallelize.md +14 -0
- data/doc/plugins/parsed_json.md +9 -0
- data/doc/plugins/presign_endpoint.md +133 -0
- data/doc/plugins/pretty_location.md +29 -0
- data/doc/plugins/processing.md +68 -0
- data/doc/plugins/rack_file.md +49 -0
- data/doc/plugins/rack_response.md +96 -0
- data/doc/plugins/recache.md +27 -0
- data/doc/plugins/refresh_metadata.md +31 -0
- data/doc/plugins/remote_url.md +104 -0
- data/doc/plugins/remove_attachment.md +16 -0
- data/doc/plugins/remove_invalid.md +9 -0
- data/doc/plugins/restore_cached_data.md +14 -0
- data/doc/plugins/sequel.md +64 -0
- data/doc/plugins/signature.md +49 -0
- data/doc/plugins/store_dimensions.md +68 -0
- data/doc/plugins/tempfile.md +40 -0
- data/doc/plugins/upload_endpoint.md +123 -0
- data/doc/plugins/upload_options.md +28 -0
- data/doc/plugins/validation_helpers.md +129 -0
- data/doc/plugins/versions.md +179 -0
- data/doc/processing.md +217 -247
- data/doc/refile.md +3 -3
- data/doc/release_notes/1.0.0.md +143 -0
- data/doc/release_notes/1.1.0.md +184 -0
- data/doc/release_notes/1.2.0.md +37 -0
- data/doc/release_notes/1.3.0.md +90 -0
- data/doc/release_notes/1.4.0.md +167 -0
- data/doc/release_notes/1.4.1.md +9 -0
- data/doc/release_notes/1.4.2.md +20 -0
- data/doc/release_notes/2.0.0.md +173 -0
- data/doc/release_notes/2.0.1.md +12 -0
- data/doc/release_notes/2.1.0.md +59 -0
- data/doc/release_notes/2.1.1.md +8 -0
- data/doc/release_notes/2.10.0.md +52 -0
- data/doc/release_notes/2.10.1.md +6 -0
- data/doc/release_notes/2.11.0.md +69 -0
- data/doc/release_notes/2.12.0.md +65 -0
- data/doc/release_notes/2.13.0.md +146 -0
- data/doc/release_notes/2.14.0.md +278 -0
- data/doc/release_notes/2.15.0.md +82 -0
- data/doc/release_notes/2.2.0.md +98 -0
- data/doc/release_notes/2.3.0.md +50 -0
- data/doc/release_notes/2.3.1.md +10 -0
- data/doc/release_notes/2.4.0.md +87 -0
- data/doc/release_notes/2.4.1.md +29 -0
- data/doc/release_notes/2.5.0.md +130 -0
- data/doc/release_notes/2.6.0.md +254 -0
- data/doc/release_notes/2.6.1.md +14 -0
- data/doc/release_notes/2.7.0.md +180 -0
- data/doc/release_notes/2.8.0.md +95 -0
- data/doc/release_notes/2.9.0.md +82 -0
- data/doc/retrieving_uploads.md +1 -1
- data/doc/storage/file_system.md +96 -0
- data/doc/storage/s3.md +293 -0
- data/doc/validation.md +1 -1
- data/lib/shrine/plugins/_urlsafe_serialization.rb +33 -125
- data/lib/shrine/plugins/activerecord.rb +0 -78
- data/lib/shrine/plugins/add_metadata.rb +0 -80
- data/lib/shrine/plugins/backgrounding.rb +0 -134
- data/lib/shrine/plugins/backup.rb +0 -22
- data/lib/shrine/plugins/cached_attachment_data.rb +0 -15
- data/lib/shrine/plugins/copy.rb +0 -14
- data/lib/shrine/plugins/data_uri.rb +0 -73
- data/lib/shrine/plugins/default_storage.rb +0 -11
- data/lib/shrine/plugins/default_url.rb +0 -25
- data/lib/shrine/plugins/default_url_options.rb +0 -16
- data/lib/shrine/plugins/delete_promoted.rb +0 -6
- data/lib/shrine/plugins/delete_raw.rb +0 -10
- data/lib/shrine/plugins/derivation_endpoint.rb +652 -0
- data/lib/shrine/plugins/determine_mime_type.rb +1 -85
- data/lib/shrine/plugins/direct_upload.rb +0 -155
- data/lib/shrine/plugins/download_endpoint.rb +11 -73
- data/lib/shrine/plugins/dynamic_storage.rb +0 -17
- data/lib/shrine/plugins/hooks.rb +0 -48
- data/lib/shrine/plugins/included.rb +0 -12
- data/lib/shrine/plugins/infer_extension.rb +0 -49
- data/lib/shrine/plugins/keep_files.rb +0 -19
- data/lib/shrine/plugins/logging.rb +0 -39
- data/lib/shrine/plugins/metadata_attributes.rb +0 -35
- data/lib/shrine/plugins/migration_helpers.rb +0 -50
- data/lib/shrine/plugins/module_include.rb +0 -32
- data/lib/shrine/plugins/moving.rb +0 -12
- data/lib/shrine/plugins/multi_delete.rb +0 -13
- data/lib/shrine/plugins/parallelize.rb +0 -8
- data/lib/shrine/plugins/parsed_json.rb +0 -5
- data/lib/shrine/plugins/presign_endpoint.rb +2 -117
- data/lib/shrine/plugins/pretty_location.rb +0 -22
- data/lib/shrine/plugins/processing.rb +0 -55
- data/lib/shrine/plugins/rack_file.rb +0 -39
- data/lib/shrine/plugins/rack_response.rb +0 -81
- data/lib/shrine/plugins/recache.rb +0 -21
- data/lib/shrine/plugins/refresh_metadata.rb +0 -24
- data/lib/shrine/plugins/remote_url.rb +0 -85
- data/lib/shrine/plugins/remove_attachment.rb +0 -10
- data/lib/shrine/plugins/remove_invalid.rb +0 -6
- data/lib/shrine/plugins/restore_cached_data.rb +0 -10
- data/lib/shrine/plugins/sequel.rb +0 -54
- data/lib/shrine/plugins/signature.rb +0 -37
- data/lib/shrine/plugins/store_dimensions.rb +0 -63
- data/lib/shrine/plugins/tempfile.rb +4 -35
- data/lib/shrine/plugins/upload_endpoint.rb +2 -109
- data/lib/shrine/plugins/upload_options.rb +0 -20
- data/lib/shrine/plugins/validation_helpers.rb +0 -36
- data/lib/shrine/plugins/versions.rb +0 -156
- data/lib/shrine/storage/file_system.rb +0 -77
- data/lib/shrine/storage/s3.rb +0 -249
- data/lib/shrine/version.rb +1 -1
- data/shrine.gemspec +2 -2
- metadata +86 -6
@@ -5,83 +5,6 @@ require "pathname"
|
|
5
5
|
|
6
6
|
class Shrine
|
7
7
|
module Storage
|
8
|
-
# The FileSystem storage handles uploads to the filesystem, and it is
|
9
|
-
# most commonly initialized with a "base" folder and a "prefix":
|
10
|
-
#
|
11
|
-
# require "shrine/storage/file_system"
|
12
|
-
#
|
13
|
-
# storage = Shrine::Storage::FileSystem.new("public", prefix: "uploads")
|
14
|
-
# storage.url("image.jpg") #=> "/uploads/image.jpg"
|
15
|
-
#
|
16
|
-
# This storage will upload all files to "public/uploads", and the URLs of
|
17
|
-
# the uploaded files will start with "/uploads/*". This way you can use
|
18
|
-
# FileSystem for both cache and store, one having the prefix
|
19
|
-
# "uploads/cache" and other "uploads/store". If you're uploading files
|
20
|
-
# to the `public` directory itself, you need to set `:prefix` to `"/"`:
|
21
|
-
#
|
22
|
-
# storage = Shrine::Storage::FileSystem.new("public", prefix: "/") # no prefix
|
23
|
-
# storage.url("image.jpg") #=> "/image.jpg"
|
24
|
-
#
|
25
|
-
# You can also initialize the storage just with the "base" directory, and
|
26
|
-
# then the FileSystem storage will generate absolute URLs to files:
|
27
|
-
#
|
28
|
-
# storage = Shrine::Storage::FileSystem.new(Dir.tmpdir)
|
29
|
-
# storage.url("image.jpg") #=> "/var/folders/k7/6zx6dx6x7ys3rv3srh0nyfj00000gn/T/image.jpg"
|
30
|
-
#
|
31
|
-
# In general you can always retrieve path to the file using `#path`:
|
32
|
-
#
|
33
|
-
# storage.path("image.jpg") #=> #<Pathname:public/image.jpg>
|
34
|
-
#
|
35
|
-
# ## Host
|
36
|
-
#
|
37
|
-
# It's generally a good idea to serve your files via a CDN, so an
|
38
|
-
# additional `:host` option can be provided to `#url`:
|
39
|
-
#
|
40
|
-
# storage = Shrine::Storage::FileSystem.new("public", prefix: "uploads")
|
41
|
-
# storage.url("image.jpg", host: "http://abc123.cloudfront.net")
|
42
|
-
# #=> "http://abc123.cloudfront.net/uploads/image.jpg"
|
43
|
-
#
|
44
|
-
# If you're not using a CDN, it's recommended that you still set `:host` to
|
45
|
-
# your application's domain (at least in production).
|
46
|
-
#
|
47
|
-
# The `:host` option can also be used wihout `:prefix`, and is
|
48
|
-
# useful if you for example have files located on another server:
|
49
|
-
#
|
50
|
-
# storage = Shrine::Storage::FileSystem.new("/opt/files")
|
51
|
-
# storage.url("image.jpg", host: "http://943.23.43.1")
|
52
|
-
# #=> "http://943.23.43.1/opt/files/image.jpg"
|
53
|
-
#
|
54
|
-
# ## Clearing cache
|
55
|
-
#
|
56
|
-
# If you're using FileSystem as cache, you will probably want to
|
57
|
-
# periodically delete old files which aren't used anymore. You can run
|
58
|
-
# something like this periodically:
|
59
|
-
#
|
60
|
-
# file_system = Shrine.storages[:cache]
|
61
|
-
# file_system.clear!(older_than: Time.now - 7*24*60*60) # delete files older than 1 week
|
62
|
-
#
|
63
|
-
# ## Permissions
|
64
|
-
#
|
65
|
-
# The storage sets the default UNIX permissions to 0644 for files and 0755
|
66
|
-
# for directories, but you can change that:
|
67
|
-
#
|
68
|
-
# Shrine::Storage::FileSystem.new("directory", permissions: 0644)
|
69
|
-
# Shrine::Storage::FileSystem.new("directory", directory_permissions: 0755)
|
70
|
-
#
|
71
|
-
# ## Heroku
|
72
|
-
#
|
73
|
-
# Note that Heroku has a read-only filesystem, and doesn't allow you to
|
74
|
-
# upload your files to the "public" directory, you can however upload to
|
75
|
-
# "tmp" directory:
|
76
|
-
#
|
77
|
-
# Shrine::Storage::FileSystem.new("tmp/uploads")
|
78
|
-
#
|
79
|
-
# Note that this approach has a couple of downsides. For example, you can
|
80
|
-
# only use it for cache, since Heroku wipes this directory between app
|
81
|
-
# restarts. This also means that deploying the app can cancel someone's
|
82
|
-
# uploading if you're using backgrounding. Also, by default you cannot
|
83
|
-
# generate URLs to files in the "tmp" directory, but you can with the
|
84
|
-
# `download_endpoint` plugin.
|
85
8
|
class FileSystem
|
86
9
|
attr_reader :directory, :prefix, :host, :permissions, :directory_permissions
|
87
10
|
|
data/lib/shrine/storage/s3.rb
CHANGED
@@ -25,255 +25,6 @@ require "tempfile"
|
|
25
25
|
|
26
26
|
class Shrine
|
27
27
|
module Storage
|
28
|
-
# The S3 storage handles uploads to Amazon S3 service, using the
|
29
|
-
# [aws-sdk-s3] gem:
|
30
|
-
#
|
31
|
-
# gem "aws-sdk-s3", "~> 1.2"
|
32
|
-
#
|
33
|
-
# It can be initialized by providing the bucket name and credentials:
|
34
|
-
#
|
35
|
-
# require "shrine/storage/s3"
|
36
|
-
#
|
37
|
-
# s3 = Shrine::Storage::S3.new(
|
38
|
-
# bucket: "my-app", # required
|
39
|
-
# access_key_id: "abc",
|
40
|
-
# secret_access_key: "xyz",
|
41
|
-
# region: "eu-west-1",
|
42
|
-
# )
|
43
|
-
#
|
44
|
-
# The core features of this storage require the following AWS permissions:
|
45
|
-
# `s3:ListBucket`, `s3:PutObject`, `s3:GetObject`, and `s3:DeleteObject`.
|
46
|
-
# If you have additional upload options configured such as setting object
|
47
|
-
# ACLs, then additional permissions may be required.
|
48
|
-
#
|
49
|
-
# The storage exposes the underlying Aws objects:
|
50
|
-
#
|
51
|
-
# s3.client #=> #<Aws::S3::Client>
|
52
|
-
# s3.client.access_key_id #=> "abc"
|
53
|
-
# s3.client.secret_access_key #=> "xyz"
|
54
|
-
# s3.client.region #=> "eu-west-1"
|
55
|
-
#
|
56
|
-
# s3.bucket #=> #<Aws::S3::Bucket>
|
57
|
-
# s3.bucket.name #=> "my-app"
|
58
|
-
#
|
59
|
-
# s3.object("key") #=> #<Aws::S3::Object>
|
60
|
-
#
|
61
|
-
# ## Public uploads
|
62
|
-
#
|
63
|
-
# By default, uploaded S3 objects will have private visibility, meaning
|
64
|
-
# they can only be accessed via signed expiring URLs generated using your
|
65
|
-
# private S3 credentials. If you would like to generate public URLs, you
|
66
|
-
# can tell S3 storage to make uploads public:
|
67
|
-
#
|
68
|
-
# s3 = Shrine::Storage::S3.new(public: true, **s3_options)
|
69
|
-
#
|
70
|
-
# s3.upload(io, "key") # uploads with "public-read" ACL
|
71
|
-
# s3.url("key") # returns public (unsigned) object URL
|
72
|
-
#
|
73
|
-
# ## Prefix
|
74
|
-
#
|
75
|
-
# The `:prefix` option can be specified for uploading all files inside
|
76
|
-
# a specific S3 prefix (folder), which is useful when using S3 for both
|
77
|
-
# cache and store:
|
78
|
-
#
|
79
|
-
# Shrine::Storage::S3.new(prefix: "cache", **s3_options)
|
80
|
-
#
|
81
|
-
# ## Upload options
|
82
|
-
#
|
83
|
-
# Sometimes you'll want to add additional upload options to all S3 uploads.
|
84
|
-
# You can do that by passing the `:upload` option:
|
85
|
-
#
|
86
|
-
# Shrine::Storage::S3.new(upload_options: { acl: "private" }, **s3_options)
|
87
|
-
#
|
88
|
-
# These options will be passed to aws-sdk-s3's methods for [uploading],
|
89
|
-
# [copying] and [presigning].
|
90
|
-
#
|
91
|
-
# You can also generate upload options per upload with the `upload_options`
|
92
|
-
# plugin
|
93
|
-
#
|
94
|
-
# class MyUploader < Shrine
|
95
|
-
# plugin :upload_options, store: ->(io, context) do
|
96
|
-
# if context[:version] == :thumb
|
97
|
-
# {acl: "public-read"}
|
98
|
-
# else
|
99
|
-
# {acl: "private"}
|
100
|
-
# end
|
101
|
-
# end
|
102
|
-
# end
|
103
|
-
#
|
104
|
-
# or when using the uploader directly
|
105
|
-
#
|
106
|
-
# uploader.upload(file, upload_options: { acl: "private" })
|
107
|
-
#
|
108
|
-
# Note that, unlike the `:upload_options` storage option, upload options
|
109
|
-
# given on the uploader level won't be forwarded for generating presigns,
|
110
|
-
# since presigns are generated using the storage directly.
|
111
|
-
#
|
112
|
-
# ## URL options
|
113
|
-
#
|
114
|
-
# This storage supports various URL options that will be forwarded from
|
115
|
-
# uploaded file.
|
116
|
-
#
|
117
|
-
# s3.url(public: true) # public URL without signed parameters
|
118
|
-
# s3.url(download: true) # forced download URL
|
119
|
-
#
|
120
|
-
# All other options are forwarded to the aws-sdk-s3 gem:
|
121
|
-
#
|
122
|
-
# s3.url(expires_in: 15, response_content_disposition: "...")
|
123
|
-
#
|
124
|
-
# ## URL Host
|
125
|
-
#
|
126
|
-
# If you want your S3 object URLs to be generated with a different URL host
|
127
|
-
# (e.g. a CDN), you can specify the `:host` option to `#url`:
|
128
|
-
#
|
129
|
-
# s3.url("image.jpg", host: "http://abc123.cloudfront.net")
|
130
|
-
# #=> "http://abc123.cloudfront.net/image.jpg"
|
131
|
-
#
|
132
|
-
# The host URL can include a path prefix, but it needs to end with a slash:
|
133
|
-
#
|
134
|
-
# s3.url("image.jpg", host: "https://your-s3-host.com/prefix/") # needs to end with a slash
|
135
|
-
# #=> "http://your-s3-host.com/prefix/image.jpg"
|
136
|
-
#
|
137
|
-
# To have the `:host` option passed automatically for every URL, use the
|
138
|
-
# `default_url_options` plugin.
|
139
|
-
#
|
140
|
-
# plugin :default_url_options, store: { host: "http://abc123.cloudfront.net" }
|
141
|
-
#
|
142
|
-
# If you would like to [serve private content via CloudFront], you need to
|
143
|
-
# sign the object URLs with a special signer, such as
|
144
|
-
# [`Aws::CloudFront::UrlSigner`] provided by the `aws-sdk-cloudfront` gem.
|
145
|
-
# The S3 storage initializer accepts a `:signer` block, which you can use
|
146
|
-
# to call your signer:
|
147
|
-
#
|
148
|
-
#
|
149
|
-
# require "aws-sdk-cloudfront"
|
150
|
-
#
|
151
|
-
# signer = Aws::CloudFront::UrlSigner.new(
|
152
|
-
# key_pair_id: "cf-keypair-id",
|
153
|
-
# private_key_path: "./cf_private_key.pem"
|
154
|
-
# )
|
155
|
-
#
|
156
|
-
# Shrine::Storage::S3.new(signer: signer.method(:signed_url))
|
157
|
-
# # or
|
158
|
-
# Shrine::Storage::S3.new(signer: -> (url, **options) { signer.signed_url(url, **options) })
|
159
|
-
#
|
160
|
-
# ## Presigns
|
161
|
-
#
|
162
|
-
# The `#presign` method can be used for generating paramters for direct
|
163
|
-
# uploads to Amazon S3:
|
164
|
-
#
|
165
|
-
# s3.presign("/path/to/file") #=>
|
166
|
-
# # {
|
167
|
-
# # url: "https://my-bucket.s3.amazonaws.com/...",
|
168
|
-
# # fields: { ... }, # blank for PUT presigns
|
169
|
-
# # headers: { ... }, # blank for POST presigns
|
170
|
-
# # method: "post",
|
171
|
-
# # }
|
172
|
-
#
|
173
|
-
# Additional presign options can be given in three places:
|
174
|
-
#
|
175
|
-
# * in `Storage::S3#presign` by forwarding options
|
176
|
-
# * in `:upload_options` option on this storage
|
177
|
-
# * in `presign_endpoint` plugin through `:presign_options`
|
178
|
-
#
|
179
|
-
# ## Large files
|
180
|
-
#
|
181
|
-
# The aws-sdk-s3 gem has the ability to automatically use multipart
|
182
|
-
# upload/copy for larger files, splitting the file into multiple chunks
|
183
|
-
# and uploading/copying them in parallel.
|
184
|
-
#
|
185
|
-
# By default any files that are uploaded will use the multipart upload
|
186
|
-
# if they're larger than 15MB, and any files that are copied will use the
|
187
|
-
# multipart copy if they're larger than 150MB, but you can change the
|
188
|
-
# thresholds via `:multipart_threshold`.
|
189
|
-
#
|
190
|
-
# thresholds = { upload: 30*1024*1024, copy: 200*1024*1024 }
|
191
|
-
# Shrine::Storage::S3.new(multipart_threshold: thresholds, **s3_options)
|
192
|
-
#
|
193
|
-
# If you want to change how many threads aws-sdk-s3 will use for multipart
|
194
|
-
# upload/copy, you can use the `upload_options` plugin to specify
|
195
|
-
# `:thread_count`.
|
196
|
-
#
|
197
|
-
# plugin :upload_options, store: -> (io, context) do
|
198
|
-
# { thread_count: 5 }
|
199
|
-
# end
|
200
|
-
#
|
201
|
-
# ## Encryption
|
202
|
-
#
|
203
|
-
# The easiest way to use server-side encryption for uploaded S3 objects is
|
204
|
-
# to configure default encryption for your S3 bucket. Alternatively, you
|
205
|
-
# can pass server-side encryption parameters to the API calls.
|
206
|
-
#
|
207
|
-
# The `#upload` method accepts `:sse_*` options:
|
208
|
-
#
|
209
|
-
# s3.upload(io, "key", sse_customer_algorithm: "AES256",
|
210
|
-
# sse_customer_key: "secret_key",
|
211
|
-
# sse_customer_key_md5: "secret_key_md5",
|
212
|
-
# ssekms_key_id: "key_id")
|
213
|
-
#
|
214
|
-
# The `#presign` method accepts `:server_side_encryption_*` options for
|
215
|
-
# POST presigns, and the same `:sse_*` options as above for PUT presigns.
|
216
|
-
#
|
217
|
-
# s3.presign("key", server_side_encryption_customer_algorithm: "AES256",
|
218
|
-
# server_side_encryption_customer_key: "secret_key",
|
219
|
-
# server_side_encryption_aws_kms_key_id: "key_id")
|
220
|
-
#
|
221
|
-
# When downloading encrypted S3 objects, the same server-side encryption
|
222
|
-
# parameters need to be passed in.
|
223
|
-
#
|
224
|
-
# s3.download("key", sse_customer_algorithm: "AES256",
|
225
|
-
# sse_customer_key: "secret_key",
|
226
|
-
# sse_customer_key_md5: "secret_key_md5")
|
227
|
-
#
|
228
|
-
# s3.open("key", sse_customer_algorithm: "AES256",
|
229
|
-
# sse_customer_key: "secret_key",
|
230
|
-
# sse_customer_key_md5: "secret_key_md5")
|
231
|
-
#
|
232
|
-
# If you want to use client-side encryption instead, you can instantiate
|
233
|
-
# the storage with an `Aws::S3::Encryption::Client` instance.
|
234
|
-
#
|
235
|
-
# client = Aws::S3::Encryption::Client.new(
|
236
|
-
# kms_key_id: "alias/my-key"
|
237
|
-
# )
|
238
|
-
#
|
239
|
-
# Shrine::Storage::S3(client: client, bucket: "my-bucket")
|
240
|
-
#
|
241
|
-
# ## Accelerate endpoint
|
242
|
-
#
|
243
|
-
# To use Amazon S3's [Transfer Acceleration] feature, you can change the
|
244
|
-
# `:endpoint` of the underlying client to the accelerate endpoint, and this
|
245
|
-
# will be applied both to regular and presigned uploads, as well as
|
246
|
-
# download URLs.
|
247
|
-
#
|
248
|
-
# Shrine::Storage::S3.new(endpoint: "https://s3-accelerate.amazonaws.com")
|
249
|
-
#
|
250
|
-
# ## Clearing cache
|
251
|
-
#
|
252
|
-
# If you're using S3 as a cache, you will probably want to periodically
|
253
|
-
# delete old files which aren't used anymore. S3 has a built-in way to do
|
254
|
-
# this, read [this article][object lifecycle] for instructions.
|
255
|
-
#
|
256
|
-
# Alternatively you can periodically call the `#clear!` method:
|
257
|
-
#
|
258
|
-
# # deletes all objects that were uploaded more than 7 days ago
|
259
|
-
# s3.clear! { |object| object.last_modified < Time.now - 7*24*60*60 }
|
260
|
-
#
|
261
|
-
# ## Request Rate and Performance Guidelines
|
262
|
-
#
|
263
|
-
# Amazon S3 automatically scales to high request rates. For example, your
|
264
|
-
# application can achieve at least 3,500 PUT/POST/DELETE and 5,500 GET
|
265
|
-
# requests per second per prefix in a bucket (a prefix is a top-level
|
266
|
-
# "directory" in the bucket). If your app needs to support higher request
|
267
|
-
# rates to S3 than that, you can scale exponentially by using more prefixes.
|
268
|
-
#
|
269
|
-
# [uploading]: http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#put-instance_method
|
270
|
-
# [copying]: http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#copy_from-instance_method
|
271
|
-
# [presigning]: http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#presigned_post-instance_method
|
272
|
-
# [aws-sdk-s3]: https://github.com/aws/aws-sdk-ruby/tree/master/gems/aws-sdk-s3
|
273
|
-
# [Transfer Acceleration]: http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html
|
274
|
-
# [object lifecycle]: http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#put-instance_method
|
275
|
-
# [serve private content via CloudFront]: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html
|
276
|
-
# [`Aws::CloudFront::UrlSigner`]: https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/CloudFront/UrlSigner.html
|
277
28
|
class S3
|
278
29
|
attr_reader :client, :bucket, :prefix, :host, :upload_options, :signer, :public
|
279
30
|
|
data/lib/shrine/version.rb
CHANGED
data/shrine.gemspec
CHANGED
@@ -23,7 +23,7 @@ direct uploads for fully asynchronous user experience.
|
|
23
23
|
gem.email = ["janko.marohnic@gmail.com"]
|
24
24
|
gem.license = "MIT"
|
25
25
|
|
26
|
-
gem.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "lib/**/*.rb", "shrine.gemspec", "doc
|
26
|
+
gem.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "lib/**/*.rb", "shrine.gemspec", "doc/**/*.md"]
|
27
27
|
gem.require_path = "lib"
|
28
28
|
|
29
29
|
gem.add_dependency "down", "~> 4.1"
|
@@ -52,5 +52,5 @@ direct uploads for fully asynchronous user experience.
|
|
52
52
|
|
53
53
|
gem.add_development_dependency "sequel"
|
54
54
|
gem.add_development_dependency "activerecord", "~> 5.2.0"
|
55
|
-
gem.add_development_dependency "sqlite3" unless RUBY_ENGINE == "jruby"
|
55
|
+
gem.add_development_dependency "sqlite3", "~> 1.3.6" unless RUBY_ENGINE == "jruby"
|
56
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: down
|
@@ -336,16 +336,16 @@ dependencies:
|
|
336
336
|
name: sqlite3
|
337
337
|
requirement: !ruby/object:Gem::Requirement
|
338
338
|
requirements:
|
339
|
-
- - "
|
339
|
+
- - "~>"
|
340
340
|
- !ruby/object:Gem::Version
|
341
|
-
version:
|
341
|
+
version: 1.3.6
|
342
342
|
type: :development
|
343
343
|
prerelease: false
|
344
344
|
version_requirements: !ruby/object:Gem::Requirement
|
345
345
|
requirements:
|
346
|
-
- - "
|
346
|
+
- - "~>"
|
347
347
|
- !ruby/object:Gem::Version
|
348
|
-
version:
|
348
|
+
version: 1.3.6
|
349
349
|
description: |
|
350
350
|
Shrine is a toolkit for file attachments in Ruby applications. It supports
|
351
351
|
uploading, downloading, processing and deleting IO objects, backed by various
|
@@ -376,11 +376,90 @@ files:
|
|
376
376
|
- doc/migrating_storage.md
|
377
377
|
- doc/multiple_files.md
|
378
378
|
- doc/paperclip.md
|
379
|
+
- doc/plugins/activerecord.md
|
380
|
+
- doc/plugins/add_metadata.md
|
381
|
+
- doc/plugins/backgrounding.md
|
382
|
+
- doc/plugins/backup.md
|
383
|
+
- doc/plugins/cached_attachment_data.md
|
384
|
+
- doc/plugins/copy.md
|
385
|
+
- doc/plugins/data_uri.md
|
386
|
+
- doc/plugins/default_storage.md
|
387
|
+
- doc/plugins/default_url.md
|
388
|
+
- doc/plugins/default_url_options.md
|
389
|
+
- doc/plugins/delete_promoted.md
|
390
|
+
- doc/plugins/delete_raw.md
|
391
|
+
- doc/plugins/derivation_endpoint.md
|
392
|
+
- doc/plugins/determine_mime_type.md
|
393
|
+
- doc/plugins/direct_upload.md
|
394
|
+
- doc/plugins/download_endpoint.md
|
395
|
+
- doc/plugins/dynamic_storage.md
|
396
|
+
- doc/plugins/hooks.md
|
397
|
+
- doc/plugins/included.md
|
398
|
+
- doc/plugins/infer_extension.md
|
399
|
+
- doc/plugins/keep_files.md
|
400
|
+
- doc/plugins/logging.md
|
401
|
+
- doc/plugins/metadata_attribues.md
|
402
|
+
- doc/plugins/migration_helpers.md
|
403
|
+
- doc/plugins/module_include.md
|
404
|
+
- doc/plugins/moving.md
|
405
|
+
- doc/plugins/multi_delete.md
|
406
|
+
- doc/plugins/parallelize.md
|
407
|
+
- doc/plugins/parsed_json.md
|
408
|
+
- doc/plugins/presign_endpoint.md
|
409
|
+
- doc/plugins/pretty_location.md
|
410
|
+
- doc/plugins/processing.md
|
411
|
+
- doc/plugins/rack_file.md
|
412
|
+
- doc/plugins/rack_response.md
|
413
|
+
- doc/plugins/recache.md
|
414
|
+
- doc/plugins/refresh_metadata.md
|
415
|
+
- doc/plugins/remote_url.md
|
416
|
+
- doc/plugins/remove_attachment.md
|
417
|
+
- doc/plugins/remove_invalid.md
|
418
|
+
- doc/plugins/restore_cached_data.md
|
419
|
+
- doc/plugins/sequel.md
|
420
|
+
- doc/plugins/signature.md
|
421
|
+
- doc/plugins/store_dimensions.md
|
422
|
+
- doc/plugins/tempfile.md
|
423
|
+
- doc/plugins/upload_endpoint.md
|
424
|
+
- doc/plugins/upload_options.md
|
425
|
+
- doc/plugins/validation_helpers.md
|
426
|
+
- doc/plugins/versions.md
|
379
427
|
- doc/processing.md
|
380
428
|
- doc/refile.md
|
381
429
|
- doc/regenerating_versions.md
|
430
|
+
- doc/release_notes/1.0.0.md
|
431
|
+
- doc/release_notes/1.1.0.md
|
432
|
+
- doc/release_notes/1.2.0.md
|
433
|
+
- doc/release_notes/1.3.0.md
|
434
|
+
- doc/release_notes/1.4.0.md
|
435
|
+
- doc/release_notes/1.4.1.md
|
436
|
+
- doc/release_notes/1.4.2.md
|
437
|
+
- doc/release_notes/2.0.0.md
|
438
|
+
- doc/release_notes/2.0.1.md
|
439
|
+
- doc/release_notes/2.1.0.md
|
440
|
+
- doc/release_notes/2.1.1.md
|
441
|
+
- doc/release_notes/2.10.0.md
|
442
|
+
- doc/release_notes/2.10.1.md
|
443
|
+
- doc/release_notes/2.11.0.md
|
444
|
+
- doc/release_notes/2.12.0.md
|
445
|
+
- doc/release_notes/2.13.0.md
|
446
|
+
- doc/release_notes/2.14.0.md
|
447
|
+
- doc/release_notes/2.15.0.md
|
448
|
+
- doc/release_notes/2.2.0.md
|
449
|
+
- doc/release_notes/2.3.0.md
|
450
|
+
- doc/release_notes/2.3.1.md
|
451
|
+
- doc/release_notes/2.4.0.md
|
452
|
+
- doc/release_notes/2.4.1.md
|
453
|
+
- doc/release_notes/2.5.0.md
|
454
|
+
- doc/release_notes/2.6.0.md
|
455
|
+
- doc/release_notes/2.6.1.md
|
456
|
+
- doc/release_notes/2.7.0.md
|
457
|
+
- doc/release_notes/2.8.0.md
|
458
|
+
- doc/release_notes/2.9.0.md
|
382
459
|
- doc/retrieving_uploads.md
|
383
460
|
- doc/securing_uploads.md
|
461
|
+
- doc/storage/file_system.md
|
462
|
+
- doc/storage/s3.md
|
384
463
|
- doc/testing.md
|
385
464
|
- doc/validation.md
|
386
465
|
- lib/shrine.rb
|
@@ -401,6 +480,7 @@ files:
|
|
401
480
|
- lib/shrine/plugins/default_url_options.rb
|
402
481
|
- lib/shrine/plugins/delete_promoted.rb
|
403
482
|
- lib/shrine/plugins/delete_raw.rb
|
483
|
+
- lib/shrine/plugins/derivation_endpoint.rb
|
404
484
|
- lib/shrine/plugins/determine_mime_type.rb
|
405
485
|
- lib/shrine/plugins/direct_upload.rb
|
406
486
|
- lib/shrine/plugins/download_endpoint.rb
|