shrine 2.15.0 → 2.16.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 +26 -0
- data/doc/advantages.md +4 -0
- data/doc/plugins/activerecord.md +3 -2
- data/doc/plugins/add_metadata.md +4 -2
- data/doc/plugins/backgrounding.md +6 -4
- data/doc/plugins/backup.md +4 -2
- data/doc/plugins/cached_attachment_data.md +5 -3
- data/doc/plugins/copy.md +3 -1
- data/doc/plugins/data_uri.md +3 -2
- data/doc/plugins/default_storage.md +5 -2
- data/doc/plugins/default_url.md +4 -2
- data/doc/plugins/default_url_options.md +5 -2
- data/doc/plugins/delete_promoted.md +6 -4
- data/doc/plugins/delete_raw.md +12 -3
- data/doc/plugins/derivation_endpoint.md +17 -6
- data/doc/plugins/determine_mime_type.md +3 -2
- data/doc/plugins/direct_upload.md +4 -2
- data/doc/plugins/download_endpoint.md +46 -6
- data/doc/plugins/dynamic_storage.md +5 -2
- data/doc/plugins/hooks.md +3 -1
- data/doc/plugins/included.md +5 -2
- data/doc/plugins/infer_extension.md +5 -4
- data/doc/plugins/keep_files.md +5 -3
- data/doc/plugins/logging.md +4 -1
- data/doc/plugins/metadata_attribues.md +6 -3
- data/doc/plugins/migration_helpers.md +4 -2
- data/doc/plugins/module_include.md +4 -2
- data/doc/plugins/moving.md +6 -4
- data/doc/plugins/multi_delete.md +4 -2
- data/doc/plugins/parallelize.md +4 -2
- data/doc/plugins/parsed_json.md +5 -3
- data/doc/plugins/presign_endpoint.md +7 -5
- data/doc/plugins/pretty_location.md +4 -2
- data/doc/plugins/processing.md +3 -2
- data/doc/plugins/rack_file.md +4 -2
- data/doc/plugins/rack_response.md +26 -10
- data/doc/plugins/recache.md +7 -5
- data/doc/plugins/refresh_metadata.md +4 -2
- data/doc/plugins/remote_url.md +3 -1
- data/doc/plugins/remove_attachment.md +4 -2
- data/doc/plugins/remove_invalid.md +6 -3
- data/doc/plugins/restore_cached_data.md +8 -6
- data/doc/plugins/sequel.md +4 -1
- data/doc/plugins/signature.md +5 -3
- data/doc/plugins/store_dimensions.md +4 -2
- data/doc/plugins/tempfile.md +4 -2
- data/doc/plugins/upload_endpoint.md +4 -3
- data/doc/plugins/upload_options.md +4 -2
- data/doc/plugins/validation_helpers.md +4 -2
- data/doc/plugins/versions.md +3 -2
- data/doc/release_notes/2.15.0.md +2 -2
- data/doc/release_notes/2.16.0.md +52 -0
- data/doc/storage/s3.md +2 -2
- data/lib/shrine/plugins/_urlsafe_serialization.rb +2 -0
- data/lib/shrine/plugins/activerecord.rb +3 -0
- data/lib/shrine/plugins/add_metadata.rb +3 -0
- data/lib/shrine/plugins/backgrounding.rb +3 -0
- data/lib/shrine/plugins/backup.rb +3 -0
- data/lib/shrine/plugins/cached_attachment_data.rb +3 -0
- data/lib/shrine/plugins/copy.rb +3 -0
- data/lib/shrine/plugins/data_uri.rb +3 -0
- data/lib/shrine/plugins/default_storage.rb +3 -0
- data/lib/shrine/plugins/default_url.rb +3 -0
- data/lib/shrine/plugins/default_url_options.rb +3 -0
- data/lib/shrine/plugins/delete_promoted.rb +3 -0
- data/lib/shrine/plugins/delete_raw.rb +4 -1
- data/lib/shrine/plugins/derivation_endpoint.rb +144 -47
- data/lib/shrine/plugins/determine_mime_type.rb +3 -0
- data/lib/shrine/plugins/direct_upload.rb +3 -0
- data/lib/shrine/plugins/download_endpoint.rb +29 -29
- data/lib/shrine/plugins/dynamic_storage.rb +3 -0
- data/lib/shrine/plugins/hooks.rb +3 -0
- data/lib/shrine/plugins/included.rb +3 -0
- data/lib/shrine/plugins/infer_extension.rb +3 -0
- data/lib/shrine/plugins/keep_files.rb +3 -0
- data/lib/shrine/plugins/logging.rb +3 -0
- data/lib/shrine/plugins/metadata_attributes.rb +3 -0
- data/lib/shrine/plugins/migration_helpers.rb +3 -0
- data/lib/shrine/plugins/module_include.rb +3 -0
- data/lib/shrine/plugins/moving.rb +3 -0
- data/lib/shrine/plugins/multi_delete.rb +3 -0
- data/lib/shrine/plugins/parallelize.rb +5 -1
- data/lib/shrine/plugins/parsed_json.rb +3 -0
- data/lib/shrine/plugins/presign_endpoint.rb +3 -0
- data/lib/shrine/plugins/pretty_location.rb +3 -0
- data/lib/shrine/plugins/processing.rb +3 -0
- data/lib/shrine/plugins/rack_file.rb +3 -0
- data/lib/shrine/plugins/rack_response.rb +14 -14
- data/lib/shrine/plugins/recache.rb +3 -0
- data/lib/shrine/plugins/refresh_metadata.rb +3 -0
- data/lib/shrine/plugins/remote_url.rb +3 -0
- data/lib/shrine/plugins/remove_attachment.rb +3 -0
- data/lib/shrine/plugins/remove_invalid.rb +3 -0
- data/lib/shrine/plugins/restore_cached_data.rb +3 -0
- data/lib/shrine/plugins/sequel.rb +3 -0
- data/lib/shrine/plugins/signature.rb +3 -0
- data/lib/shrine/plugins/store_dimensions.rb +4 -1
- data/lib/shrine/plugins/tempfile.rb +5 -0
- data/lib/shrine/plugins/upload_endpoint.rb +3 -0
- data/lib/shrine/plugins/upload_options.rb +3 -0
- data/lib/shrine/plugins/validation_helpers.rb +3 -0
- data/lib/shrine/plugins/versions.rb +3 -0
- data/lib/shrine/uploaded_file.rb +15 -7
- data/lib/shrine/version.rb +1 -1
- metadata +3 -2
data/doc/plugins/hooks.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Hooks
|
2
2
|
|
3
|
-
The `hooks` plugin allows you to trigger some code around
|
3
|
+
The [`hooks`][hooks] plugin allows you to trigger some code around
|
4
4
|
processing/storing/deleting of each file.
|
5
5
|
|
6
6
|
```rb
|
@@ -54,3 +54,5 @@ class ImageUploader < Shrine
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
```
|
57
|
+
|
58
|
+
[hooks]: /lib/shrine/plugins/hooks.rb
|
data/doc/plugins/included.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Included
|
2
2
|
|
3
|
-
The `included` plugin allows you to hook up to the `.included` hook
|
4
|
-
attachment module, and call additional methods on the model which
|
3
|
+
The [`included`][included] plugin allows you to hook up to the `.included` hook
|
4
|
+
of the attachment module, and call additional methods on the model which
|
5
|
+
includes it.
|
5
6
|
|
6
7
|
```rb
|
7
8
|
plugin :included do |name|
|
@@ -13,3 +14,5 @@ end
|
|
13
14
|
|
14
15
|
If you want to define additional methods on the model, it's recommended to use
|
15
16
|
the `module_include` plugin instead.
|
17
|
+
|
18
|
+
[included]: /lib/shrine/plugins/included.rb
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Infer Extension
|
2
2
|
|
3
|
-
The `infer_extension` plugin allows deducing the appropriate
|
4
|
-
the upload location based on the MIME type of the file. This
|
5
|
-
using `data_uri` and `remote_url` plugins, where the file
|
6
|
-
be known.
|
3
|
+
The [`infer_extension`][infer_extension] plugin allows deducing the appropriate
|
4
|
+
file extension for the upload location based on the MIME type of the file. This
|
5
|
+
is useful when using `data_uri` and `remote_url` plugins, where the file
|
6
|
+
extension might not be known.
|
7
7
|
|
8
8
|
```rb
|
9
9
|
plugin :infer_extension
|
@@ -53,5 +53,6 @@ Shrine.extension_inferrers[:mime_types].call("image/jpeg")
|
|
53
53
|
# => ".jpeg"
|
54
54
|
```
|
55
55
|
|
56
|
+
[infer_extension]: /lib/shrine/plugins/infer_extension.rb
|
56
57
|
[mime-types]: https://github.com/mime-types/ruby-mime-types
|
57
58
|
[mini_mime]: https://github.com/discourse/mini_mime
|
data/doc/plugins/keep_files.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Keep Files
|
2
2
|
|
3
|
-
The `keep_files` plugin gives you the ability to prevent files
|
4
|
-
deleted. This functionality is useful when implementing soft
|
5
|
-
implementing some kind of [event store] where you need to
|
3
|
+
The [`keep_files`][keep_files] plugin gives you the ability to prevent files
|
4
|
+
from being deleted. This functionality is useful when implementing soft
|
5
|
+
deletes, or when implementing some kind of [event store] where you need to
|
6
|
+
track history.
|
6
7
|
|
7
8
|
The plugin accepts the following options:
|
8
9
|
|
@@ -17,4 +18,5 @@ For example, the following will keep destroyed and replaced files:
|
|
17
18
|
plugin :keep_files, destroyed: true, replaced: true
|
18
19
|
```
|
19
20
|
|
21
|
+
[keep_files]: /lib/shrine/plugins/keep_files.rb
|
20
22
|
[event store]: http://docs.geteventstore.com/introduction/event-sourcing-basics/
|
data/doc/plugins/logging.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Logging
|
2
2
|
|
3
|
-
The `logging` plugin logs any storing/processing/deleting that is
|
3
|
+
The [`logging`][logging] plugin logs any storing/processing/deleting that is
|
4
|
+
performed.
|
4
5
|
|
5
6
|
```rb
|
6
7
|
plugin :logging
|
@@ -37,3 +38,5 @@ plugin :logging, format: :logfmt
|
|
37
38
|
|
38
39
|
Logging is by default disabled in tests, but you can enable it by setting
|
39
40
|
`Shrine.logger.level = Logger::INFO`.
|
41
|
+
|
42
|
+
[logging]: /lib/shrine/plugins/logging.rb
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# Metadata Attributes
|
2
2
|
|
3
|
-
The `metadata_attributes` plugin allows you to sync
|
4
|
-
additional record attributes. You can provide a hash of
|
5
|
-
call itself or the `Attacher.metadata_attributes`
|
3
|
+
The [`metadata_attributes`][metadata_attributes] plugin allows you to sync
|
4
|
+
attachment metadata to additional record attributes. You can provide a hash of
|
5
|
+
mappings to the plugin call itself or the `Attacher.metadata_attributes`
|
6
|
+
method:
|
6
7
|
|
7
8
|
```rb
|
8
9
|
plugin :metadata_attributes, :size => :size, :mime_type => :type
|
@@ -41,3 +42,5 @@ photo.original_filename #=> "nature.jpg"
|
|
41
42
|
|
42
43
|
If any corresponding metadata attribute doesn't exist on the record, that
|
43
44
|
metadata sync will be silently skipped.
|
45
|
+
|
46
|
+
[metadata_attributes]: /lib/shrine/plugins/metadata_attributes.rb
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Migration Helpers
|
2
2
|
|
3
|
-
The migration_helpers plugin gives the attacher
|
4
|
-
are convenient when doing file migrations.
|
3
|
+
The [`migration_helpers`][migration_helpers] plugin gives the attacher
|
4
|
+
additional helper methods which are convenient when doing file migrations.
|
5
5
|
|
6
6
|
The plugin also allows convenient delegating to these methods through the
|
7
7
|
model, by setting `:delegate`:
|
@@ -56,3 +56,5 @@ user.avatar_attacher.store #=> #<Shrine @storage_key=:store @storage=#<Shrine::S
|
|
56
56
|
user.avatar_cache
|
57
57
|
user.avatar_store
|
58
58
|
```
|
59
|
+
|
60
|
+
[migration_helpers]: /lib/shrine/plugins/migration_helpers.rb
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Module Include
|
2
2
|
|
3
|
-
The `module_include` plugin allows you to extend Shrine's
|
4
|
-
given uploader with modules/methods.
|
3
|
+
The [`module_include`][module_include] plugin allows you to extend Shrine's
|
4
|
+
core classes for the given uploader with modules/methods.
|
5
5
|
|
6
6
|
```rb
|
7
7
|
plugin :module_include
|
@@ -38,3 +38,5 @@ end
|
|
38
38
|
|
39
39
|
The above defines an additional `#<attachment>_size` method on the attachment
|
40
40
|
module, which is what is included in your model.
|
41
|
+
|
42
|
+
[module_include]: /lib/shrine/plugins/module_include.rb
|
data/doc/plugins/moving.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Moving
|
2
2
|
|
3
|
-
The `moving` plugin will *move* files to storages instead of copying
|
4
|
-
the storage supports it. For FileSystem this will issue a `mv`
|
5
|
-
is instantaneous regardless of the filesize, so in that case
|
6
|
-
plugin can significantly speed up the attachment process.
|
3
|
+
The [`moving`][moving] plugin will *move* files to storages instead of copying
|
4
|
+
them, when the storage supports it. For FileSystem this will issue a `mv`
|
5
|
+
command, which is instantaneous regardless of the filesize, so in that case
|
6
|
+
loading this plugin can significantly speed up the attachment process.
|
7
7
|
|
8
8
|
```rb
|
9
9
|
plugin :moving
|
@@ -15,3 +15,5 @@ moving to happen only for certain storages, you can set `:storages`:
|
|
15
15
|
```rb
|
16
16
|
plugin :moving, storages: [:cache]
|
17
17
|
```
|
18
|
+
|
19
|
+
[moving]: /lib/shrine/plugins/moving.rb
|
data/doc/plugins/multi_delete.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Multi Delete
|
2
2
|
|
3
|
-
The `multi_delete` plugins allows you to leverage your
|
4
|
-
capabilities.
|
3
|
+
The [`multi_delete`][multi_delete] plugins allows you to leverage your
|
4
|
+
storage's multi delete capabilities.
|
5
5
|
|
6
6
|
```rb
|
7
7
|
plugin :multi_delete
|
@@ -16,3 +16,5 @@ uploader.delete([file1, file2, file3])
|
|
16
16
|
Now if you're using Storage::S3, deleting an array of files will issue a single
|
17
17
|
HTTP request. Some other storages may support multi deletes as well. The
|
18
18
|
`versions` plugin uses this plugin for deleting multiple versions at once.
|
19
|
+
|
20
|
+
[multi_delete]: /lib/shrine/plugins/multi_delete.rb
|
data/doc/plugins/parallelize.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Parallelize
|
2
2
|
|
3
|
-
The `parallelize` plugin parallelizes uploads and deletes of
|
4
|
-
using threads.
|
3
|
+
The [`parallelize`][parallelize] plugin parallelizes uploads and deletes of
|
4
|
+
multiple versions using threads.
|
5
5
|
|
6
6
|
```rb
|
7
7
|
plugin :parallelize
|
@@ -12,3 +12,5 @@ By default a pool of 3 threads will be used, but you can change that:
|
|
12
12
|
```rb
|
13
13
|
plugin :parallelize, threads: 5
|
14
14
|
```
|
15
|
+
|
16
|
+
[parallelize]: /lib/shrine/plugins/parallelize.rb
|
data/doc/plugins/parsed_json.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Parsed JSON
|
2
2
|
|
3
|
-
The `parsed_json` plugin is suitable for the case when your
|
4
|
-
automatically parsing JSON query parameters, allowing you to
|
5
|
-
files with hashes/arrays.
|
3
|
+
The [`parsed_json`][parsed_json] plugin is suitable for the case when your
|
4
|
+
framework is automatically parsing JSON query parameters, allowing you to
|
5
|
+
assign cached files with hashes/arrays.
|
6
6
|
|
7
7
|
```rb
|
8
8
|
plugin :parsed_json
|
9
9
|
```
|
10
|
+
|
11
|
+
[parsed_json]: /lib/shrine/plugins/parsed_json.rb
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# Presign Endpoint
|
2
2
|
|
3
|
-
The `presign_endpoint` plugin provides a Rack endpoint
|
4
|
-
fields, and headers that can be used to upload files
|
5
|
-
service. On the client side it's recommended to use
|
6
|
-
uploads. Storage services that support direct uploads
|
7
|
-
[Google Cloud Storage], [Microsoft Azure Storage] and
|
3
|
+
The [`presign_endpoint`][presign_endpoint] plugin provides a Rack endpoint
|
4
|
+
which generates the URL, fields, and headers that can be used to upload files
|
5
|
+
directly to a storage service. On the client side it's recommended to use
|
6
|
+
[Uppy] for asynchronous uploads. Storage services that support direct uploads
|
7
|
+
include [Amazon S3], [Google Cloud Storage], [Microsoft Azure Storage] and
|
8
|
+
more.
|
8
9
|
|
9
10
|
```rb
|
10
11
|
plugin :presign_endpoint
|
@@ -126,6 +127,7 @@ You can override any of the options above when creating the endpoint:
|
|
126
127
|
Shrine.presign_endpoint(:cache, presign_location: "${filename}")
|
127
128
|
```
|
128
129
|
|
130
|
+
[presign_endpoint]: /lib/shrine/plugins/presign_endpoint.rb
|
129
131
|
[Uppy]: https://uppy.io
|
130
132
|
[Amazon S3]: https://aws.amazon.com/s3/
|
131
133
|
[Google Cloud Storage]: https://cloud.google.com/storage/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Pretty Location
|
2
2
|
|
3
|
-
The `pretty_location` plugin attempts to generate a nicer
|
4
|
-
uploaded files.
|
3
|
+
The [`pretty_location`][pretty_location] plugin attempts to generate a nicer
|
4
|
+
folder structure for uploaded files.
|
5
5
|
|
6
6
|
```rb
|
7
7
|
plugin :pretty_location
|
@@ -27,3 +27,5 @@ plugin :pretty_location, namespace: "_"
|
|
27
27
|
plugin :pretty_location, namespace: "/"
|
28
28
|
# "blog/user/.../493g82jf23.jpg"
|
29
29
|
```
|
30
|
+
|
31
|
+
[pretty_location]: /lib/shrine/plugins/pretty_location.rb
|
data/doc/plugins/processing.md
CHANGED
@@ -22,8 +22,8 @@ def process(io, context)
|
|
22
22
|
end
|
23
23
|
```
|
24
24
|
|
25
|
-
The `processing` plugin simplifies this by allowing us to
|
26
|
-
file processing for specified actions.
|
25
|
+
The [`processing`][processing] plugin simplifies this by allowing us to
|
26
|
+
declaratively define file processing for specified actions.
|
27
27
|
|
28
28
|
```rb
|
29
29
|
plugin :processing
|
@@ -65,4 +65,5 @@ uploader.process(file, action: :store) # only process
|
|
65
65
|
If you want the result of processing to be multiple files, use the `versions`
|
66
66
|
plugin.
|
67
67
|
|
68
|
+
[processing]: /lib/shrine/plugins/processing.rb
|
68
69
|
[image_processing]: https://github.com/janko/image_processing
|
data/doc/plugins/rack_file.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Rack File
|
2
2
|
|
3
|
-
The `rack_file` plugin enables uploaders to accept Rack uploaded
|
4
|
-
for uploading.
|
3
|
+
The [`rack_file`][rack_file] plugin enables uploaders to accept Rack uploaded
|
4
|
+
file hashes for uploading.
|
5
5
|
|
6
6
|
```rb
|
7
7
|
plugin :rack_file
|
@@ -47,3 +47,5 @@ io.size #=> 58342
|
|
47
47
|
Note that this plugin is not needed in Rails applications, as Rails already
|
48
48
|
wraps the Rack uploaded file hash into an `ActionDispatch::Http::UploadedFile`
|
49
49
|
object.
|
50
|
+
|
51
|
+
[rack_file]: /lib/shrine/plugins/rack_file.rb
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Rack Response
|
2
2
|
|
3
|
-
The `rack_response` plugin allows you to convert an
|
4
|
-
a triple consisting of status, headers, and body,
|
5
|
-
response in a Rack-based application.
|
3
|
+
The [`rack_response`][rack_response] plugin allows you to convert an
|
4
|
+
`UploadedFile` object into a triple consisting of status, headers, and body,
|
5
|
+
suitable for returning as a response in a Rack-based application.
|
6
6
|
|
7
7
|
```rb
|
8
8
|
plugin :rack_response
|
@@ -53,8 +53,8 @@ The response `Content-Type` header will default to the value of the `mime_type`
|
|
53
53
|
metadata. A custom content type can be provided via the `:type` option:
|
54
54
|
|
55
55
|
```rb
|
56
|
-
|
57
|
-
|
56
|
+
response = uploaded_file.to_rack_response(type: "text/plain; charset=utf-8")
|
57
|
+
response[1]["Content-Type"] #=> "text/plain; charset=utf-8"
|
58
58
|
```
|
59
59
|
|
60
60
|
## Filename
|
@@ -64,8 +64,8 @@ value of the `filename` metadata. A custom download filename can be provided
|
|
64
64
|
via the `:filename` option:
|
65
65
|
|
66
66
|
```rb
|
67
|
-
|
68
|
-
|
67
|
+
response = uploaded_file.to_rack_response(filename: "my-filename.txt")
|
68
|
+
response[1]["Content-Disposition"] #=> "inline; filename=\"my-filename.txt\""
|
69
69
|
```
|
70
70
|
|
71
71
|
## Disposition
|
@@ -74,8 +74,8 @@ The default disposition in the "Content-Disposition" header is `inline`, but it
|
|
74
74
|
can be changed via the `:disposition` option:
|
75
75
|
|
76
76
|
```rb
|
77
|
-
|
78
|
-
|
77
|
+
response = uploaded_file.to_rack_response(disposition: "attachment")
|
78
|
+
response[1]["Content-Disposition"] #=> "attachment; filename=\"file.txt\""
|
79
79
|
```
|
80
80
|
|
81
81
|
## Range
|
@@ -84,7 +84,6 @@ headers["Content-Disposition"] #=> "attachment; filename=\"file.txt\""
|
|
84
84
|
which accepts a value of the `Range` request header.
|
85
85
|
|
86
86
|
```rb
|
87
|
-
env["HTTP_RANGE"] #=> "bytes=100-200"
|
88
87
|
status, headers, body = uploaded_file.to_rack_response(range: env["HTTP_RANGE"])
|
89
88
|
status #=> 206
|
90
89
|
headers["Content-Length"] #=> "101"
|
@@ -92,5 +91,22 @@ headers["Content-Range"] #=> "bytes 100-200/1000"
|
|
92
91
|
body # partial content
|
93
92
|
```
|
94
93
|
|
94
|
+
## Download options
|
95
|
+
|
96
|
+
The `#to_rack_response` method will automatically open the `UploadedFile` if it
|
97
|
+
hasn't been opened yet. If you want to pass additional download options to the
|
98
|
+
storage, you can explicitly call `UploadedFile#open` beforehand:
|
99
|
+
|
100
|
+
```rb
|
101
|
+
uploaded_file.open(
|
102
|
+
sse_customer_algorithm: "AES256",
|
103
|
+
sse_customer_key: "secret_key",
|
104
|
+
sse_customer_key_md5: "secret_key_md5",
|
105
|
+
)
|
106
|
+
|
107
|
+
uploaded_file.to_rack_response
|
108
|
+
```
|
109
|
+
|
110
|
+
[rack_response]: /lib/shrine/plugins/rack_response.rb
|
95
111
|
[range requests]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests
|
96
112
|
[Rack::Sendfile]: https://www.rubydoc.info/github/rack/rack/Rack/Sendfile
|
data/doc/plugins/recache.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Re-cache
|
2
2
|
|
3
|
-
The `recache` plugin allows you to process your attachment after
|
4
|
-
succeed, but before the attachment is promoted. This is useful for
|
5
|
-
you want to generate some versions upfront (so the user
|
6
|
-
and other versions you want to generate in the promotion
|
7
|
-
job.
|
3
|
+
The [`recache`][recache] plugin allows you to process your attachment after
|
4
|
+
validations succeed, but before the attachment is promoted. This is useful for
|
5
|
+
example when you want to generate some versions upfront (so the user
|
6
|
+
immediately sees them) and other versions you want to generate in the promotion
|
7
|
+
phase in a background job.
|
8
8
|
|
9
9
|
```rb
|
10
10
|
plugin :recache
|
@@ -25,3 +25,5 @@ you're using the attacher directly, you can call it manually:
|
|
25
25
|
```rb
|
26
26
|
attacher.recache if attacher.changed?
|
27
27
|
```
|
28
|
+
|
29
|
+
[recache]: /lib/shrine/plugins/recache.rb
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Refresh Metadata
|
2
2
|
|
3
|
-
The `refresh_metadata` plugin allows you to re-extract
|
4
|
-
uploaded file.
|
3
|
+
The [`refresh_metadata`][refresh_metadata] plugin allows you to re-extract
|
4
|
+
metadata from an uploaded file.
|
5
5
|
|
6
6
|
```rb
|
7
7
|
plugin :refresh_metadata
|
@@ -29,3 +29,5 @@ uploaded_file.open do
|
|
29
29
|
# ...
|
30
30
|
end
|
31
31
|
```
|
32
|
+
|
33
|
+
[refresh_metadata]: /lib/shrine/plugins/refresh_metadata.rb
|
data/doc/plugins/remote_url.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Remote URL
|
2
2
|
|
3
|
-
The `remote_url` plugin allows you to attach files from a remote
|
3
|
+
The [`remote_url`][remote_url] plugin allows you to attach files from a remote
|
4
|
+
location.
|
4
5
|
|
5
6
|
```rb
|
6
7
|
plugin :remote_url, max_size: 20*1024*1024
|
@@ -100,5 +101,6 @@ load the `infer_extension` plugin to infer it from the MIME type.
|
|
100
101
|
plugin :infer_extension
|
101
102
|
```
|
102
103
|
|
104
|
+
[remote_url]: /lib/shrine/plugins/remote_url.rb
|
103
105
|
[Down]: https://github.com/janko/down
|
104
106
|
[shrine-url]: https://github.com/shrinerb/shrine-url
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Remove Attachment
|
2
2
|
|
3
|
-
The `remove_attachment` plugin allows you to delete
|
4
|
-
checkboxes on the web form.
|
3
|
+
The [`remove_attachment`][remove_attachment] plugin allows you to delete
|
4
|
+
attachments through checkboxes on the web form.
|
5
5
|
|
6
6
|
```rb
|
7
7
|
plugin :remove_attachment
|
@@ -14,3 +14,5 @@ to add a form field for removing attachments:
|
|
14
14
|
```rb
|
15
15
|
form.check_box :remove_avatar
|
16
16
|
```
|
17
|
+
|
18
|
+
[remove_attachment]: /lib/shrine/plugins/remove_attachment.rb
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# Remove Invalid
|
2
2
|
|
3
|
-
The `remove_invalid` plugin automatically deletes a new
|
4
|
-
invalid and deassigns it from the record. If there was
|
5
|
-
attached, it will be assigned back, otherwise no attachment
|
3
|
+
The [`remove_invalid`][remove_invalid] plugin automatically deletes a new
|
4
|
+
assigned file if it was invalid and deassigns it from the record. If there was
|
5
|
+
a previous file attached, it will be assigned back, otherwise no attachment
|
6
|
+
will be assigned.
|
6
7
|
|
7
8
|
```rb
|
8
9
|
plugin :remove_invalid
|
9
10
|
```
|
11
|
+
|
12
|
+
[remove_invalid]: /lib/shrine/plugins/remove_invalid.rb
|