shrine 3.0.0.rc → 3.0.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.

Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -66
  3. data/README.md +39 -1061
  4. data/doc/advantages.md +151 -148
  5. data/doc/attacher.md +12 -30
  6. data/doc/carrierwave.md +150 -115
  7. data/doc/changing_derivatives.md +5 -11
  8. data/doc/changing_location.md +8 -5
  9. data/doc/changing_storage.md +5 -2
  10. data/doc/creating_persistence_plugins.md +9 -6
  11. data/doc/creating_plugins.md +42 -22
  12. data/doc/creating_storages.md +4 -1
  13. data/doc/design.md +7 -5
  14. data/doc/direct_s3.md +9 -4
  15. data/doc/external/articles.md +50 -0
  16. data/doc/external/extensions.md +46 -0
  17. data/doc/external/misc.md +17 -0
  18. data/doc/getting_started.md +1038 -0
  19. data/doc/metadata.md +5 -3
  20. data/doc/multiple_files.md +55 -29
  21. data/doc/paperclip.md +206 -163
  22. data/doc/plugins/activerecord.md +26 -6
  23. data/doc/plugins/add_metadata.md +4 -2
  24. data/doc/plugins/atomic_helpers.md +4 -2
  25. data/doc/plugins/backgrounding.md +83 -44
  26. data/doc/plugins/cached_attachment_data.md +4 -2
  27. data/doc/plugins/column.md +4 -2
  28. data/doc/plugins/data_uri.md +10 -6
  29. data/doc/plugins/default_storage.md +5 -3
  30. data/doc/plugins/default_url.md +4 -2
  31. data/doc/plugins/delete_raw.md +4 -2
  32. data/doc/plugins/derivation_endpoint.md +63 -39
  33. data/doc/plugins/derivatives.md +13 -50
  34. data/doc/plugins/determine_mime_type.md +6 -4
  35. data/doc/plugins/download_endpoint.md +6 -3
  36. data/doc/plugins/dynamic_storage.md +4 -2
  37. data/doc/plugins/entity.md +6 -4
  38. data/doc/plugins/form_assign.md +4 -2
  39. data/doc/plugins/included.md +4 -2
  40. data/doc/plugins/infer_extension.md +6 -4
  41. data/doc/plugins/instrumentation.md +5 -3
  42. data/doc/plugins/keep_files.md +9 -2
  43. data/doc/plugins/metadata_attributes.md +5 -3
  44. data/doc/plugins/mirroring.md +4 -2
  45. data/doc/plugins/model.md +6 -4
  46. data/doc/plugins/module_include.md +4 -2
  47. data/doc/plugins/multi_cache.md +4 -2
  48. data/doc/plugins/persistence.md +5 -3
  49. data/doc/plugins/presign_endpoint.md +6 -2
  50. data/doc/plugins/pretty_location.md +5 -3
  51. data/doc/plugins/processing.md +4 -2
  52. data/doc/plugins/rack_file.md +8 -2
  53. data/doc/plugins/rack_response.md +6 -2
  54. data/doc/plugins/recache.md +4 -2
  55. data/doc/plugins/refresh_metadata.md +5 -3
  56. data/doc/plugins/remote_url.md +26 -5
  57. data/doc/plugins/remove_attachment.md +4 -2
  58. data/doc/plugins/remove_invalid.md +10 -2
  59. data/doc/plugins/restore_cached_data.md +9 -3
  60. data/doc/plugins/sequel.md +26 -6
  61. data/doc/plugins/signature.md +6 -4
  62. data/doc/plugins/store_dimensions.md +6 -4
  63. data/doc/plugins/tempfile.md +4 -2
  64. data/doc/plugins/upload_endpoint.md +6 -2
  65. data/doc/plugins/upload_options.md +6 -4
  66. data/doc/plugins/url_options.md +4 -2
  67. data/doc/plugins/validation.md +7 -3
  68. data/doc/plugins/validation_helpers.md +13 -10
  69. data/doc/plugins/versions.md +4 -8
  70. data/doc/processing.md +27 -9
  71. data/doc/refile.md +119 -127
  72. data/doc/release_notes/1.0.0.md +4 -0
  73. data/doc/release_notes/1.1.0.md +4 -0
  74. data/doc/release_notes/1.2.0.md +4 -0
  75. data/doc/release_notes/1.3.0.md +4 -0
  76. data/doc/release_notes/1.4.0.md +4 -0
  77. data/doc/release_notes/1.4.1.md +4 -0
  78. data/doc/release_notes/1.4.2.md +4 -0
  79. data/doc/release_notes/2.0.0.md +4 -0
  80. data/doc/release_notes/2.0.1.md +4 -0
  81. data/doc/release_notes/2.1.0.md +4 -0
  82. data/doc/release_notes/2.1.1.md +4 -0
  83. data/doc/release_notes/2.10.0.md +4 -0
  84. data/doc/release_notes/2.10.1.md +4 -0
  85. data/doc/release_notes/2.11.0.md +4 -0
  86. data/doc/release_notes/2.12.0.md +4 -0
  87. data/doc/release_notes/2.13.0.md +4 -0
  88. data/doc/release_notes/2.14.0.md +5 -1
  89. data/doc/release_notes/2.15.0.md +10 -6
  90. data/doc/release_notes/2.16.0.md +4 -0
  91. data/doc/release_notes/2.17.0.md +4 -0
  92. data/doc/release_notes/2.18.0.md +4 -0
  93. data/doc/release_notes/2.19.0.md +7 -4
  94. data/doc/release_notes/2.2.0.md +4 -0
  95. data/doc/release_notes/2.3.0.md +4 -0
  96. data/doc/release_notes/2.3.1.md +4 -0
  97. data/doc/release_notes/2.4.0.md +4 -0
  98. data/doc/release_notes/2.4.1.md +4 -0
  99. data/doc/release_notes/2.5.0.md +4 -0
  100. data/doc/release_notes/2.6.0.md +4 -0
  101. data/doc/release_notes/2.6.1.md +4 -0
  102. data/doc/release_notes/2.7.0.md +4 -0
  103. data/doc/release_notes/2.8.0.md +4 -0
  104. data/doc/release_notes/2.9.0.md +4 -0
  105. data/doc/release_notes/3.0.0.md +120 -38
  106. data/doc/retrieving_uploads.md +4 -1
  107. data/doc/securing_uploads.md +4 -1
  108. data/doc/storage/file_system.md +12 -4
  109. data/doc/storage/s3.md +4 -2
  110. data/doc/testing.md +27 -41
  111. data/doc/upgrading_to_3.md +105 -26
  112. data/doc/validation.md +8 -6
  113. data/lib/shrine/attacher.rb +2 -2
  114. data/lib/shrine/attachment.rb +7 -10
  115. data/lib/shrine/plugins/activerecord.rb +10 -10
  116. data/lib/shrine/plugins/add_metadata.rb +1 -3
  117. data/lib/shrine/plugins/atomic_helpers.rb +6 -8
  118. data/lib/shrine/plugins/backgrounding.rb +4 -6
  119. data/lib/shrine/plugins/cached_attachment_data.rb +1 -3
  120. data/lib/shrine/plugins/column.rb +2 -4
  121. data/lib/shrine/plugins/data_uri.rb +1 -3
  122. data/lib/shrine/plugins/default_storage.rb +1 -3
  123. data/lib/shrine/plugins/default_url.rb +1 -3
  124. data/lib/shrine/plugins/delete_raw.rb +1 -3
  125. data/lib/shrine/plugins/derivation_endpoint.rb +3 -4
  126. data/lib/shrine/plugins/derivatives.rb +2 -4
  127. data/lib/shrine/plugins/determine_mime_type.rb +1 -3
  128. data/lib/shrine/plugins/download_endpoint.rb +1 -3
  129. data/lib/shrine/plugins/dynamic_storage.rb +1 -3
  130. data/lib/shrine/plugins/entity.rb +25 -9
  131. data/lib/shrine/plugins/form_assign.rb +1 -3
  132. data/lib/shrine/plugins/included.rb +1 -3
  133. data/lib/shrine/plugins/infer_extension.rb +1 -3
  134. data/lib/shrine/plugins/instrumentation.rb +1 -3
  135. data/lib/shrine/plugins/keep_files.rb +1 -3
  136. data/lib/shrine/plugins/metadata_attributes.rb +1 -3
  137. data/lib/shrine/plugins/mirroring.rb +2 -1
  138. data/lib/shrine/plugins/model.rb +2 -4
  139. data/lib/shrine/plugins/module_include.rb +1 -3
  140. data/lib/shrine/plugins/multi_cache.rb +3 -3
  141. data/lib/shrine/plugins/presign_endpoint.rb +1 -3
  142. data/lib/shrine/plugins/pretty_location.rb +1 -3
  143. data/lib/shrine/plugins/processing.rb +1 -3
  144. data/lib/shrine/plugins/rack_file.rb +1 -3
  145. data/lib/shrine/plugins/rack_response.rb +1 -3
  146. data/lib/shrine/plugins/recache.rb +1 -3
  147. data/lib/shrine/plugins/refresh_metadata.rb +1 -3
  148. data/lib/shrine/plugins/remote_url.rb +1 -3
  149. data/lib/shrine/plugins/remove_attachment.rb +1 -3
  150. data/lib/shrine/plugins/remove_invalid.rb +1 -3
  151. data/lib/shrine/plugins/restore_cached_data.rb +1 -3
  152. data/lib/shrine/plugins/sequel.rb +10 -12
  153. data/lib/shrine/plugins/signature.rb +1 -3
  154. data/lib/shrine/plugins/store_dimensions.rb +1 -3
  155. data/lib/shrine/plugins/tempfile.rb +1 -3
  156. data/lib/shrine/plugins/upload_endpoint.rb +1 -3
  157. data/lib/shrine/plugins/upload_options.rb +1 -3
  158. data/lib/shrine/plugins/url_options.rb +1 -3
  159. data/lib/shrine/plugins/validation.rb +1 -3
  160. data/lib/shrine/plugins/validation_helpers.rb +1 -3
  161. data/lib/shrine/plugins/versions.rb +1 -3
  162. data/lib/shrine/storage/file_system.rb +1 -1
  163. data/lib/shrine/storage/linter.rb +1 -1
  164. data/lib/shrine/storage/memory.rb +2 -1
  165. data/lib/shrine/storage/s3.rb +3 -3
  166. data/lib/shrine/version.rb +1 -1
  167. metadata +8 -4
@@ -1,4 +1,6 @@
1
- # Processing
1
+ ---
2
+ title: Processing
3
+ ---
2
4
 
3
5
  Shrine uploaders can define the `#process` method, which will get called
4
6
  whenever a file is uploaded. It is given the original file, and is expected to
@@ -65,5 +67,5 @@ uploader.process(file, action: :store) # only process
65
67
  If you want the result of processing to be multiple files, use the `versions`
66
68
  plugin.
67
69
 
68
- [processing]: /lib/shrine/plugins/processing.rb
70
+ [processing]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/processing.rb
69
71
  [image_processing]: https://github.com/janko/image_processing
@@ -1,4 +1,6 @@
1
- # Rack File
1
+ ---
2
+ title: Rack File
3
+ ---
2
4
 
3
5
  The [`rack_file`][rack_file] plugin enables uploaders to accept Rack uploaded
4
6
  file hashes for uploading.
@@ -7,6 +9,8 @@ file hashes for uploading.
7
9
  plugin :rack_file
8
10
  ```
9
11
 
12
+ ## Usage
13
+
10
14
  When a file is uploaded to your Rack application using the
11
15
  `multipart/form-data` parameter encoding, Rack converts the uploaded file to a
12
16
  hash.
@@ -33,6 +37,8 @@ user.avatar = file_hash
33
37
  attacher.assign(file_hash)
34
38
  ```
35
39
 
40
+ ## API
41
+
36
42
  Internally the Rack uploaded file hash will be converted into an IO object
37
43
  using `Shrine.rack_file`, which you can also use directly:
38
44
 
@@ -48,4 +54,4 @@ Note that this plugin is not needed in Rails applications, as Rails already
48
54
  wraps the Rack uploaded file hash into an `ActionDispatch::Http::UploadedFile`
49
55
  object.
50
56
 
51
- [rack_file]: /lib/shrine/plugins/rack_file.rb
57
+ [rack_file]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/rack_file.rb
@@ -1,4 +1,6 @@
1
- # Rack Response
1
+ ---
2
+ title: Rack Response
3
+ ---
2
4
 
3
5
  The [`rack_response`][rack_response] plugin allows you to convert an
4
6
  `UploadedFile` object into a triple consisting of status, headers, and body,
@@ -8,6 +10,8 @@ suitable for returning as a response in a Rack-based application.
8
10
  plugin :rack_response
9
11
  ```
10
12
 
13
+ ## Usage
14
+
11
15
  To convert a `Shrine::UploadedFile` into a Rack response, simply call
12
16
  `#to_rack_response`:
13
17
 
@@ -107,6 +111,6 @@ uploaded_file.open(
107
111
  uploaded_file.to_rack_response
108
112
  ```
109
113
 
110
- [rack_response]: /lib/shrine/plugins/rack_response.rb
114
+ [rack_response]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/rack_response.rb
111
115
  [range requests]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests
112
116
  [Rack::Sendfile]: https://www.rubydoc.info/github/rack/rack/Rack/Sendfile
@@ -1,4 +1,6 @@
1
- # Re-cache
1
+ ---
2
+ title: Re-cache
3
+ ---
2
4
 
3
5
  The [`recache`][recache] plugin allows you to process your attachment after
4
6
  validations succeed, but before the attachment is promoted. This is useful for
@@ -26,4 +28,4 @@ you're using the attacher directly, you can call it manually:
26
28
  attacher.recache if attacher.changed?
27
29
  ```
28
30
 
29
- [recache]: /lib/shrine/plugins/recache.rb
31
+ [recache]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/recache.rb
@@ -1,4 +1,6 @@
1
- # Refresh Metadata
1
+ ---
2
+ title: Refresh Metadata
3
+ ---
2
4
 
3
5
  The [`refresh_metadata`][refresh_metadata] plugin allows you to re-extract
4
6
  metadata from an uploaded file.
@@ -66,5 +68,5 @@ Any options passed in will be forwarded to metadata extraction:
66
68
  uploaded_file.refresh_metadata!(foo: "bar") # passes `{ foo: "bar" }` options to metadata extraction
67
69
  ```
68
70
 
69
- [refresh_metadata]: /lib/shrine/plugins/refresh_metadata.rb
70
- [model]: /doc/plugins/model.md#readme
71
+ [refresh_metadata]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/refresh_metadata.rb
72
+ [model]: https://shrinerb.com/docs/plugins/model
@@ -1,4 +1,6 @@
1
- # Remote URL
1
+ ---
2
+ title: Remote URL
3
+ ---
2
4
 
3
5
  The [`remote_url`][remote_url] plugin allows you to attach files from a remote
4
6
  location.
@@ -7,6 +9,8 @@ location.
7
9
  plugin :remote_url, max_size: 20*1024*1024
8
10
  ```
9
11
 
12
+ ## Usage
13
+
10
14
  The plugin will add the `#<name>_remote_url` writer to your model, which
11
15
  downloads the remote file and uploads it to temporary storage.
12
16
 
@@ -27,7 +31,7 @@ attacher.file.size #=> 43423
27
31
  attacher.file.original_filename #=> "cool-image.png"
28
32
  ```
29
33
 
30
- ## Downloading
34
+ ## Downloader
31
35
 
32
36
  By default, the file will be downloaded using `Down.download` from the [Down]
33
37
  gem. This will use the [Down::NetHttp] backend by default, which is a wrapper
@@ -70,6 +74,23 @@ plugin :remote_url, downloader: -> (url, **options) {
70
74
  }
71
75
  ```
72
76
 
77
+ ### Calling downloader
78
+
79
+ You can call the downloader directly with `Shrine.remote_url`:
80
+
81
+ ```rb
82
+ # or YourUploader.remote_url(...)
83
+ file = Shrine.remote_url("https://example.com/image.jpg")
84
+ file #=> #<Tempfile:...>
85
+ ```
86
+
87
+ You can pass additional options as well:
88
+
89
+ ```rb
90
+ # or YourUploader.remote_url(...)
91
+ Shrine.remote_url("https://example.com/image.jpg", headers: { "Cookie" => "..." })
92
+ ```
93
+
73
94
  ## Uploader options
74
95
 
75
96
  Any additional options passed to `Attacher#assign_remote_url` will be forwarded
@@ -145,7 +166,7 @@ following payload:
145
166
 
146
167
  A default log subscriber is added as well which logs these events:
147
168
 
148
- ```
169
+ ```plaintext
149
170
  Remote URL (1550ms) – {:remote_url=>"https://example.com/image.jpg",:download_options=>{},:uploader=>Shrine}
150
171
  ```
151
172
 
@@ -156,7 +177,7 @@ plugin :remote_url, log_subscriber: -> (event) {
156
177
  Shrine.logger.info JSON.generate(name: event.name, duration: event.duration, **event.payload)
157
178
  }
158
179
  ```
159
- ```
180
+ ```plaintext
160
181
  {"name":"remote_url","duration":5,"remote_url":"https://example.com/image.jpg","download_options":{},"uploader":"Shrine"}
161
182
  ```
162
183
 
@@ -166,7 +187,7 @@ Or disable logging altogether:
166
187
  plugin :remote_url, log_subscriber: nil
167
188
  ```
168
189
 
169
- [remote_url]: /lib/shrine/plugins/remote_url.rb
190
+ [remote_url]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/remote_url.rb
170
191
  [Down]: https://github.com/janko/down
171
192
  [Down::NetHttp]: https://github.com/janko/down#downnethttp
172
193
  [open-uri]: https://ruby-doc.org/stdlib/libdoc/open-uri/rdoc/OpenURI.html
@@ -1,4 +1,6 @@
1
- # Remove Attachment
1
+ ---
2
+ title: Remove Attachment
3
+ ---
2
4
 
3
5
  The [`remove_attachment`][remove_attachment] plugin allows you to delete
4
6
  attachments through checkboxes on the web form.
@@ -34,4 +36,4 @@ attacher.remove = '1'
34
36
  attacher.file #=> nil
35
37
  ```
36
38
 
37
- [remove_attachment]: /lib/shrine/plugins/remove_attachment.rb
39
+ [remove_attachment]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/remove_attachment.rb
@@ -1,4 +1,6 @@
1
- # Remove Invalid
1
+ ---
2
+ title: Remove Invalid
3
+ ---
2
4
 
3
5
  The [`remove_invalid`][remove_invalid] plugin automatically deletes and
4
6
  deassigns a new assigned file if it was invalid. If there was a previous file
@@ -8,4 +10,10 @@ attached, it will be assigned back.
8
10
  plugin :remove_invalid
9
11
  ```
10
12
 
11
- [remove_invalid]: /lib/shrine/plugins/remove_invalid.rb
13
+ ```rb
14
+ photo.image = file # invalid file
15
+ photo.valid? #=> false
16
+ photo.image #=> nil
17
+ ```
18
+
19
+ [remove_invalid]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/remove_invalid.rb
@@ -1,4 +1,6 @@
1
- # Restore Cached Data
1
+ ---
2
+ title: Restore Cached Data
3
+ ---
2
4
 
3
5
  The [`restore_cached_data`][restore_cached_data] plugin re-extracts metadata
4
6
  when assigning already cached files, i.e. when the attachment has been retained
@@ -10,9 +12,13 @@ extracted on the client side.
10
12
  ```rb
11
13
  plugin :restore_cached_data
12
14
  ```
15
+ ```rb
16
+ photo.image = { "id" => "path/to/image.jpg", "storage" => "cache", "metadata" => {} }
17
+ photo.image.metadata #=> { "size" => 4823763, "mime_type" => "image/jpeg", ... }
18
+ ```
13
19
 
14
20
  It uses the [`refresh_metadata`][refresh_metadata] plugin to re-extract
15
21
  metadata.
16
22
 
17
- [restore_cached_data]: /lib/shrine/plugins/restore_cached_data.rb
18
- [refresh_metadata]: /doc/plugins/refresh_metadata.md#readme
23
+ [restore_cached_data]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/restore_cached_data.rb
24
+ [refresh_metadata]: https://shrinerb.com/docs/plugins/refresh_metadata
@@ -1,10 +1,12 @@
1
- # Sequel
1
+ ---
2
+ title: Sequel
3
+ ---
2
4
 
3
5
  The [`sequel`][sequel] plugin adds [Sequel] integration to the attachment
4
6
  interface. It is built on top of the [`model`][model] plugin.
5
7
 
6
8
  ```rb
7
- plugin :sequel
9
+ Shrine.plugin :sequel
8
10
  ```
9
11
 
10
12
  ## Attachment
@@ -71,6 +73,24 @@ photo.destroy
71
73
  photo.image.exists? #=> false
72
74
  ```
73
75
 
76
+ #### Overriding hooks
77
+
78
+ You can override any of the following attacher methods to modify callback
79
+ behaviour:
80
+
81
+ * `Attacher#sequel_before_save`
82
+ * `Attacher#sequel_after_save`
83
+ * `Attacher#sequel_after_destroy`
84
+
85
+ ```rb
86
+ class Shrine::Attacher
87
+ def sequel_after_save
88
+ super
89
+ # ...
90
+ end
91
+ end
92
+ ```
93
+
74
94
  #### Skipping Hooks
75
95
 
76
96
  If you don't want the attachment module to add any hooks to your model, you can
@@ -164,8 +184,8 @@ The following persistence methods are added to `Shrine::Attacher`:
164
184
 
165
185
  See [persistence] docs for more details.
166
186
 
167
- [sequel]: /lib/shrine/plugins/sequel.rb
187
+ [sequel]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/sequel.rb
168
188
  [Sequel]: https://sequel.jeremyevans.net/
169
- [model]: /doc/plugins/model.md#readme
170
- [validation]: /doc/plugins/validation.md#readme
171
- [persistence]: /doc/plugins/persistence.md#readme
189
+ [model]: https://shrinerb.com/docs/plugins/model
190
+ [validation]: https://shrinerb.com/docs/plugins/validation
191
+ [persistence]: https://shrinerb.com/docs/plugins/persistence
@@ -1,4 +1,6 @@
1
- # Signature
1
+ ---
2
+ title: Signature
3
+ ---
2
4
 
3
5
  The [`signature`][signature] plugin provides the ability to calculate a hash
4
6
  from file content. This hash can be used as a checksum or just as a unique
@@ -74,7 +76,7 @@ following payload:
74
76
 
75
77
  A default log subscriber is added as well which logs these events:
76
78
 
77
- ```
79
+ ```plaintext
78
80
  MIME Type (33ms) – {:io=>StringIO, :uploader=>Shrine}
79
81
  ```
80
82
 
@@ -85,7 +87,7 @@ plugin :signature, log_subscriber: -> (event) {
85
87
  Shrine.logger.info JSON.generate(name: event.name, duration: event.duration, **event.payload)
86
88
  }
87
89
  ```
88
- ```
90
+ ```plaintext
89
91
  {"name":"signature","duration":24,"io":"#<StringIO:0x00007fb7c5b08b80>","uploader":"Shrine"}
90
92
  ```
91
93
 
@@ -95,4 +97,4 @@ Or disable logging altogether:
95
97
  plugin :signature, log_subscriber: nil
96
98
  ```
97
99
 
98
- [signature]: /lib/shrine/plugins/signature.rb
100
+ [signature]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/signature.rb
@@ -1,4 +1,6 @@
1
- # Store Dimensions
1
+ ---
2
+ title: Store Dimensions
3
+ ---
2
4
 
3
5
  The [`store_dimensions`][store_dimensions] plugin extracts dimensions of
4
6
  uploaded images and stores them into the metadata hash (by default it uses the
@@ -108,7 +110,7 @@ following payload:
108
110
 
109
111
  A default log subscriber is added as well which logs these events:
110
112
 
111
- ```
113
+ ```plaintext
112
114
  Image Dimensions (108ms) – {:io=>File, :uploader=>Shrine}
113
115
  ```
114
116
 
@@ -119,7 +121,7 @@ plugin :store_dimensions, log_subscriber: -> (event) {
119
121
  Shrine.logger.info JSON.generate(name: event.name, duration: event.duration, **event.payload)
120
122
  }
121
123
  ```
122
- ```
124
+ ```plaintext
123
125
  {"name":"image_dimensions","duration":114,"io":"#<File:0x00007fc445371d90>","uploader":"Shrine"}
124
126
  ```
125
127
 
@@ -129,7 +131,7 @@ Or disable logging altogether:
129
131
  plugin :store_dimensions, log_subscriber: nil
130
132
  ```
131
133
 
132
- [store_dimensions]: /lib/shrine/plugins/store_dimensions.rb
134
+ [store_dimensions]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/store_dimensions.rb
133
135
  [fastimage]: https://github.com/sdsykes/fastimage
134
136
  [mini_magick]: https://github.com/minimagick/minimagick
135
137
  [ruby-vips]: https://github.com/libvips/ruby-vips
@@ -1,4 +1,6 @@
1
- # Tempfile
1
+ ---
2
+ title: Tempfile
3
+ ---
2
4
 
3
5
  The [`tempfile`][tempfile] plugin makes it easier to reuse a single copy of an
4
6
  uploaded file on disk.
@@ -39,4 +41,4 @@ when the given IO object is an open `UploadedFile`. Since `Shrine.with_file` is
39
41
  typically called on the `Shrine` class directly, it's recommended to load this
40
42
  plugin globally.
41
43
 
42
- [tempfile]: /lib/shrine/plugins/tempfile.rb
44
+ [tempfile]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/tempfile.rb
@@ -1,4 +1,6 @@
1
- # Upload Endpoint
1
+ ---
2
+ title: Upload Endpoint
3
+ ---
2
4
 
3
5
  The [`upload_endpoint`][upload_endpoint] plugin provides a Rack endpoint which
4
6
  accepts file uploads and forwards them to specified storage. On the client side
@@ -8,6 +10,8 @@ it's recommended to use [Uppy] for asynchronous uploads.
8
10
  plugin :upload_endpoint
9
11
  ```
10
12
 
13
+ ## Setup
14
+
11
15
  The plugin adds a `Shrine.upload_endpoint` method which, given a storage
12
16
  identifier, returns a Rack application that accepts multipart POST requests,
13
17
  and uploads received files to the specified storage. You can run this Rack
@@ -173,5 +177,5 @@ and the endpoint will automatically use it to verify the uploaded data.
173
177
 
174
178
  If the checksums don't match, a `460 Checksum Mismatch` response is returned.
175
179
 
176
- [upload_endpoint]: /lib/shrine/plugins/upload_endpoint.rb
180
+ [upload_endpoint]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/upload_endpoint.rb
177
181
  [Uppy]: https://uppy.io
@@ -1,4 +1,6 @@
1
- # Upload Options
1
+ ---
2
+ title: Upload Options
3
+ ---
2
4
 
3
5
  The [`upload_options`][upload_options] plugin allows you to automatically pass
4
6
  additional upload options to storage on every upload:
@@ -11,8 +13,8 @@ Keys are names of the registered storages, and values are either hashes or
11
13
  blocks.
12
14
 
13
15
  ```rb
14
- plugin :upload_options, store: -> (io, context) do
15
- if [:original, :thumb].include?(context[:version])
16
+ plugin :upload_options, store: -> (io, **options) do
17
+ if options[:derivative]
16
18
  { acl: "public-read" }
17
19
  else
18
20
  { acl: "private" }
@@ -27,4 +29,4 @@ the uploader.
27
29
  uploader.upload(file, upload_options: { acl: "public-read" })
28
30
  ```
29
31
 
30
- [upload_options]: /lib/shrine/plugins/upload_options.rb
32
+ [upload_options]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/upload_options.rb
@@ -1,4 +1,6 @@
1
- # URL Options
1
+ ---
2
+ title: URL Options
3
+ ---
2
4
 
3
5
  The [`url_options`][url_options] plugin allows you to specify
4
6
  URL options that will be applied by default for uploaded files of specified
@@ -22,4 +24,4 @@ In both cases the default options are merged with options passed to
22
24
  `UploadedFile#url`, and the latter will always have precedence over default
23
25
  options.
24
26
 
25
- [url_options]: /lib/shrine/plugins/url_options.rb
27
+ [url_options]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/url_options.rb
@@ -1,4 +1,6 @@
1
- # Validation
1
+ ---
2
+ title: Validation
3
+ ---
2
4
 
3
5
  The [`validation`][validation] plugin provides a framework for validating
4
6
  attached files. For some useful validators, see the
@@ -8,6 +10,8 @@ attached files. For some useful validators, see the
8
10
  plugin :validation
9
11
  ```
10
12
 
13
+ ## Usage
14
+
11
15
  The `Attacher.validate` method is used to register a validation block, which
12
16
  is called on attachment:
13
17
 
@@ -79,5 +83,5 @@ You can also skip validation by passing `validate: false`:
79
83
  attacher.assign(file, validate: false) # skips validation
80
84
  ```
81
85
 
82
- [validation]: /lib/shrine/plugins/validation.rb
83
- [validation_helpers]: /doc/plugins/validation_helpers.md#readme
86
+ [validation]: https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/validation.rb
87
+ [validation_helpers]: https://shrinerb.com/docs/plugins/validation_helpers