shrine 2.18.1 → 2.19.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 +53 -1
- data/README.md +96 -137
- data/doc/advantages.md +4 -4
- data/doc/attacher.md +1 -2
- data/doc/carrierwave.md +3 -2
- data/doc/creating_storages.md +0 -20
- data/doc/design.md +1 -1
- data/doc/metadata.md +62 -36
- data/doc/paperclip.md +7 -6
- data/doc/plugins/data_uri.md +50 -4
- data/doc/plugins/derivation_endpoint.md +24 -0
- data/doc/plugins/determine_mime_type.md +47 -5
- data/doc/plugins/infer_extension.md +45 -9
- data/doc/plugins/instrumentation.md +170 -0
- data/doc/plugins/presign_endpoint.md +1 -1
- data/doc/plugins/pretty_location.md +23 -0
- data/doc/plugins/remote_url.md +59 -8
- data/doc/plugins/signature.md +54 -7
- data/doc/plugins/store_dimensions.md +69 -4
- data/doc/plugins/upload_endpoint.md +2 -2
- data/doc/plugins/validation_helpers.md +71 -29
- data/doc/refile.md +1 -1
- data/doc/release_notes/2.18.0.md +2 -2
- data/doc/release_notes/2.19.0.md +263 -0
- data/doc/storage/file_system.md +26 -8
- data/doc/testing.md +10 -10
- data/lib/shrine.rb +32 -16
- data/lib/shrine/attacher.rb +3 -0
- data/lib/shrine/attachment.rb +3 -0
- data/lib/shrine/plugins/add_metadata.rb +12 -16
- data/lib/shrine/plugins/backup.rb +2 -0
- data/lib/shrine/plugins/copy.rb +2 -0
- data/lib/shrine/plugins/data_uri.rb +56 -28
- data/lib/shrine/plugins/derivation_endpoint.rb +61 -27
- data/lib/shrine/plugins/determine_mime_type.rb +27 -5
- data/lib/shrine/plugins/infer_extension.rb +26 -5
- data/lib/shrine/plugins/instrumentation.rb +300 -0
- data/lib/shrine/plugins/logging.rb +2 -0
- data/lib/shrine/plugins/moving.rb +2 -0
- data/lib/shrine/plugins/pretty_location.rb +21 -12
- data/lib/shrine/plugins/rack_file.rb +23 -18
- data/lib/shrine/plugins/refresh_metadata.rb +4 -4
- data/lib/shrine/plugins/remote_url.rb +42 -23
- data/lib/shrine/plugins/signature.rb +32 -1
- data/lib/shrine/plugins/store_dimensions.rb +54 -9
- data/lib/shrine/plugins/validation_helpers.rb +148 -47
- data/lib/shrine/storage/file_system.rb +32 -15
- data/lib/shrine/storage/linter.rb +0 -13
- data/lib/shrine/storage/s3.rb +2 -5
- data/lib/shrine/uploaded_file.rb +8 -0
- data/lib/shrine/version.rb +2 -2
- data/shrine.gemspec +18 -3
- metadata +58 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4986c5f02d23d23bb5b40c9c9d6bab5bdc3ed10506fd3ef5d171a8176e5f75fb
|
4
|
+
data.tar.gz: b09a2c063f78e9711feec2a9a026e7198ae31623af96e609dc0683d7969e9b7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93df569fa078dddc0dd0ca60a74e15b929f633bc3614b4fcec608814e8578fc29ef5398803a0b3d02a9cfc4e436aff4125f8f59644fa4e014913f5be2e9eb7b3
|
7
|
+
data.tar.gz: 41a66f59ba0195a7ecac244ff687a87562005eb801d0d3651e08148dcfee6b3f598b91fd410a0c3ad11be84561c9f295f540e2c17e036a0882ec8828aebe3383
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,56 @@
|
|
1
|
-
## 2.
|
1
|
+
## 2.19.0 (2019-07-18)
|
2
|
+
|
3
|
+
* `pretty_location` – Allow specifying a different identifier from `id` (@00dav00)
|
4
|
+
|
5
|
+
* `data_uri` – Soft-move `Shrine::Plugins::DataUri::DataFile` to `Shrine::DataFile` (@janko)
|
6
|
+
|
7
|
+
* `rack_file` – Soft-move `Shrine::Plugins::RackFile::UploadedFile` to `Shrine::RackFile` (@janko)
|
8
|
+
|
9
|
+
* `backup` – Deprecate the plugin over [mirroring uploads](https://github.com/shrinerb/shrine/wiki/Mirroring-Uploads) via the `instrumentation` plugin (@janko)
|
10
|
+
|
11
|
+
* `moving` – Deprecate the plugin in favor of the `:move` option for `FileSystem#upload` (@janko)
|
12
|
+
|
13
|
+
* `file_system` – Add `:move` option for `FileSystem#upload` (@janko)
|
14
|
+
|
15
|
+
* `file_system` – Don't fill `size` metadata if missing in `FileSystem#upload` (@janko)
|
16
|
+
|
17
|
+
* `logging` – Deprecate plugin in favour of `instrumentation` (@janko)
|
18
|
+
|
19
|
+
* `instrumentation` – Add plugin which sends events via `ActiveSupport::Notifications` or `dry-monitor` (@janko)
|
20
|
+
|
21
|
+
* `core` – Add `UploadedFile#[]` shorthand for accessing metadata (@janko)
|
22
|
+
|
23
|
+
* `add_metadata` – Allow calling `super` when overriding dynamically defined `UploadedFile` methods (@janko)
|
24
|
+
|
25
|
+
* `store_dimensions` – Add `:on_error` option for specifying the exception strategy (@janko)
|
26
|
+
|
27
|
+
* `store_dimensions` – Print warnings when exception occurred while extracting dimensions (@janko)
|
28
|
+
|
29
|
+
* `core` – Add `Shrine.logger` and make any warnings go through it (@janko)
|
30
|
+
|
31
|
+
* `copy` – Deprecate the plugin (@janko)
|
32
|
+
|
33
|
+
* `core` – Add ability to force metadata extraction by passing `metadata: true` to `Shrine#upload` (@janko)
|
34
|
+
|
35
|
+
* `core` – Add ability to skip metadata extraction by passing `metadata: false` to `Shrine#upload` (@janko)
|
36
|
+
|
37
|
+
* `file_system` – Deprecate `:older_than` option for `FileSystem#clear!` in favour of a block (@janko)
|
38
|
+
|
39
|
+
* `file_system` – Add the ability for `FileSystem#clear!` to take a block (@janko)
|
40
|
+
|
41
|
+
* `signature` – Add `Shrine.signature` alias for `Shrine.calculcate_signature` (@janko)
|
42
|
+
|
43
|
+
* `store_dimensions` – Add `Shrine.dimensions` alias for `Shrine.extract_dimensions` (@janko)
|
44
|
+
|
45
|
+
* `determine_mime_type` – Add `Shrine.mime_type` alias for `Shrine.determine_mime_type` (@janko)
|
46
|
+
|
47
|
+
* `validation_helpers` – Add `#validate_max_dimensions`, `#validate_min_dimensions`, and `#validate_dimensions` (@janko)
|
48
|
+
|
49
|
+
* `validation_helpers` - Add `#validate_size`, `#validate_width`, and `#validate_height` shorthands (@janko)
|
50
|
+
|
51
|
+
* `validation_helpers` – Add `#validate_mime_type` and `#validate_extension` aliases for inclusion (@janko)
|
52
|
+
|
53
|
+
* `validation_helpers` – Simplify default validation error messages (@janko)
|
2
54
|
|
3
55
|
* `core` – Allow registering storage objects under string keys (@janko)
|
4
56
|
|
data/README.md
CHANGED
@@ -50,7 +50,7 @@ If you're curious how it compares to other file attachment libraries, see the [A
|
|
50
50
|
- [Resumable direct upload](#resumable-direct-upload)
|
51
51
|
* [Backgrounding](#backgrounding)
|
52
52
|
* [Clearing cache](#clearing-cache)
|
53
|
-
* [
|
53
|
+
* [Logging](#logging)
|
54
54
|
|
55
55
|
## Quick start
|
56
56
|
|
@@ -197,7 +197,7 @@ the uploaded file with `#<attachment>_url` and display it on the page:
|
|
197
197
|
A "storage" in Shrine is an object that encapsulates communication with a
|
198
198
|
specific storage service, by implementing a common public interface. Storage
|
199
199
|
instances are registered under an identifier in `Shrine.storages`, so that they
|
200
|
-
can later
|
200
|
+
can later be used by [uploaders][uploader].
|
201
201
|
|
202
202
|
Previously we've shown the [FileSystem] storage which saves files to disk, but
|
203
203
|
Shrine also ships with [S3] storage which stores files on [AWS S3] (or any
|
@@ -324,7 +324,7 @@ uploaded_file = uploader.upload(file)
|
|
324
324
|
uploaded_file.data #=> {"id"=>"949sdjg834.jpg","storage"=>"store","metadata"=>{...}}
|
325
325
|
|
326
326
|
uploaded_file.id #=> "949sdjg834.jpg"
|
327
|
-
uploaded_file.storage #=> #<Shrine::Storage::
|
327
|
+
uploaded_file.storage #=> #<Shrine::Storage::S3>
|
328
328
|
uploaded_file.metadata #=> {...}
|
329
329
|
```
|
330
330
|
|
@@ -355,7 +355,7 @@ For more details, see the [Retrieving Uploads] guide and
|
|
355
355
|
|
356
356
|
## Attachment
|
357
357
|
|
358
|
-
|
358
|
+
Storage objects, uploaders, and uploaded file objects are Shrine's foundational
|
359
359
|
components. To help you actually attach uploaded files to database records in
|
360
360
|
your application, Shrine comes with a high-level attachment interface built on
|
361
361
|
top of these components.
|
@@ -456,7 +456,7 @@ ship with Shrine. This way you can choose exactly what and how much Shrine does
|
|
456
456
|
for you, and you load the code only for features that you use.
|
457
457
|
|
458
458
|
```rb
|
459
|
-
Shrine.plugin :
|
459
|
+
Shrine.plugin :instrumentation # adds instrumentation
|
460
460
|
```
|
461
461
|
|
462
462
|
Plugins add behaviour by extending Shrine core classes via module inclusion, and
|
@@ -494,23 +494,23 @@ uploaded_file.size #=> 345993
|
|
494
494
|
|
495
495
|
### MIME type
|
496
496
|
|
497
|
-
By default, `mime_type` metadata will be
|
498
|
-
|
499
|
-
a warning. You can load the [`determine_mime_type`][determine_mime_type
|
500
|
-
plugin to have MIME type extracted from file *content* instead.
|
497
|
+
By default, `mime_type` metadata will be set from the `#content_type` attribute
|
498
|
+
of the uploaded file (if it exists), which is generally not secure and will
|
499
|
+
trigger a warning. You can load the [`determine_mime_type`][determine_mime_type
|
500
|
+
plugin] plugin to have MIME type extracted from file *content* instead.
|
501
501
|
|
502
502
|
```rb
|
503
|
-
|
503
|
+
# Gemfile
|
504
|
+
gem "marcel", "~> 0.3"
|
505
|
+
```
|
506
|
+
```rb
|
507
|
+
Shrine.plugin :determine_mime_type, analyzer: :marcel
|
504
508
|
```
|
505
509
|
```rb
|
506
510
|
photo = Photo.create(image: StringIO.new("<?php ... ?>"))
|
507
|
-
photo.image.mime_type #=> "
|
511
|
+
photo.image.mime_type #=> "application/x-php"
|
508
512
|
```
|
509
513
|
|
510
|
-
By the default the UNIX [`file`] utility is used to determine the MIME type,
|
511
|
-
but you can also choose a different analyzer, see the
|
512
|
-
[`determine_mime_type`][determine_mime_type plugin] docs for more details.
|
513
|
-
|
514
514
|
### Other metadata
|
515
515
|
|
516
516
|
In addition to basic metadata, you can also extract [image
|
@@ -711,19 +711,27 @@ can also access the extracted metadata through `context[:metadata]`.
|
|
711
711
|
|
712
712
|
To improve the user experience, it's recommended to upload files asynchronously
|
713
713
|
as soon as the user selects them. The direct uploads would go to temporary
|
714
|
-
storage, just like in the synchronous flow.
|
714
|
+
storage, just like in the synchronous flow. Then, instead of attaching a raw
|
715
|
+
file to your model, you assign the cached file JSON data.
|
716
|
+
|
717
|
+
```rb
|
718
|
+
# in the regular synchronous flow
|
719
|
+
photo.image = file
|
715
720
|
|
716
|
-
|
717
|
-
|
718
|
-
|
721
|
+
# in the direct upload flow
|
722
|
+
photo.image = '{"id":"...","storage":"cache","metadata":{...}}'
|
723
|
+
```
|
724
|
+
|
725
|
+
On the client side it's highly recommended to use **[Uppy]** :dog:, a very
|
726
|
+
flexible modern JavaScript file upload library that happens to integrate nicely
|
727
|
+
with Shrine.
|
719
728
|
|
720
729
|
### Simple direct upload
|
721
730
|
|
722
|
-
The simplest approach is
|
723
|
-
|
731
|
+
The simplest approach is to upload directly to an endpoint in your app, which
|
732
|
+
forwards uploads to the specified storage. The
|
724
733
|
[`upload_endpoint`][upload_endpoint plugin] Shrine plugin provides a
|
725
|
-
[mountable][Mounting Endpoints] Rack
|
726
|
-
combine it with Uppy's [XHR Upload][uppy xhr-upload] plugin:
|
734
|
+
[mountable][Mounting Endpoints] Rack app that implements this endpoint:
|
727
735
|
|
728
736
|
```rb
|
729
737
|
Shrine.plugin :upload_endpoint
|
@@ -735,22 +743,11 @@ Rails.application.routes.draw do
|
|
735
743
|
mount ImageUploader.upload_endpoint(:cache) => "/images/upload" # POST /images/upload
|
736
744
|
end
|
737
745
|
```
|
738
|
-
```js
|
739
|
-
// upload.js
|
740
|
-
// ...
|
741
|
-
uppy.use(Uppy.XHRUpload, {
|
742
|
-
endpoint: '/images/upload'
|
743
|
-
})
|
744
|
-
|
745
|
-
uppy.on('upload-success', (file, response) => {
|
746
|
-
const uploadedFileData = JSON.stringify(response.body)
|
747
|
-
// ... add this data to your form or submit it to your app ...
|
748
|
-
})
|
749
|
-
```
|
750
746
|
|
751
|
-
|
752
|
-
|
753
|
-
|
747
|
+
Then you can configure Uppy's [XHR Upload][uppy xhr-upload] plugin to upload to
|
748
|
+
this endpoint. See [this walkthrough][Adding Direct App Uploads] for adding
|
749
|
+
simple direct uploads from scratch, it includes a complete JavaScript example
|
750
|
+
(there is also the [Roda][roda demo] / [Rails][rails demo] demo app).
|
754
751
|
|
755
752
|
### Presigned direct upload
|
756
753
|
|
@@ -768,10 +765,9 @@ Shrine.storages = {
|
|
768
765
|
```
|
769
766
|
|
770
767
|
In this flow, the client needs to first fetch upload parameters from the
|
771
|
-
server, and then use these parameters for the upload to the cloud service.
|
772
|
-
[`presign_endpoint`][presign_endpoint plugin] Shrine plugin provides a
|
773
|
-
[mountable][Mounting Endpoints] Rack
|
774
|
-
parameters, and you can combine it with Uppy's [AWS S3][uppy aws-s3] plugin:
|
768
|
+
server, and then use these parameters for the upload to the cloud service.
|
769
|
+
The [`presign_endpoint`][presign_endpoint plugin] Shrine plugin provides a
|
770
|
+
[mountable][Mounting Endpoints] Rack app that generates upload parameters:
|
775
771
|
|
776
772
|
```rb
|
777
773
|
Shrine.plugin :presign_endpoint
|
@@ -783,43 +779,24 @@ Rails.application.routes.draw do
|
|
783
779
|
mount Shrine.presign_endpoint(:cache) => "/s3/params" # GET /s3/params
|
784
780
|
end
|
785
781
|
```
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
uppy.on('upload-success', (file, response) => {
|
794
|
-
const uploadedFileData = JSON.stringify({
|
795
|
-
id: file.meta['key'].match(/^cache\/(.+)/)[1], // object key without prefix
|
796
|
-
storage: 'cache',
|
797
|
-
metadata: {
|
798
|
-
size: file.size,
|
799
|
-
filename: file.name,
|
800
|
-
mime_type: file.type,
|
801
|
-
}
|
802
|
-
})
|
803
|
-
// ... add this data to your form or submit it to your app ...
|
804
|
-
})
|
805
|
-
```
|
806
|
-
|
807
|
-
For adding direct S3 uploads from scratch, see [this walkthrough][Adding Direct
|
808
|
-
S3 Uploads] (there is also the [Roda][roda demo] / [Rails][rails demo] demo).
|
809
|
-
See also the [Direct Uploads to S3] guide for more details.
|
782
|
+
|
783
|
+
Then you can configure Uppy's [AWS S3][uppy aws-s3] plugin to fetch params from
|
784
|
+
your endpoint before uploading to S3. See [this walkthrough][Adding Direct S3
|
785
|
+
Uploads] for adding direct uploads to S3 from scratch, it includes a complete
|
786
|
+
JavaScript example (there is also the [Roda][roda demo] / [Rails][rails demo]
|
787
|
+
demo). See also the [Direct Uploads to S3] guide for more details.
|
810
788
|
|
811
789
|
### Resumable direct upload
|
812
790
|
|
813
|
-
If your app is accepting large uploads, you can
|
814
|
-
This can significantly improve experience for users
|
815
|
-
connections.
|
791
|
+
If your app is accepting large uploads, you can improve resilience by making
|
792
|
+
the uploads **resumable**. This can significantly improve experience for users
|
793
|
+
on slow and flaky internet connections.
|
816
794
|
|
817
795
|
#### Uppy S3 Multipart
|
818
796
|
|
819
797
|
You can achieve resumable uploads directly to S3 with the [AWS S3
|
820
|
-
Multipart][uppy aws-s3-multipart] Uppy plugin, accompanied with
|
821
|
-
plugin provided by the [uppy-s3_multipart] gem
|
822
|
-
is `Shrine::Storage::S3`):
|
798
|
+
Multipart][uppy aws-s3-multipart] Uppy plugin, accompanied with
|
799
|
+
`uppy_s3_multipart` Shrine plugin provided by the [uppy-s3_multipart] gem.
|
823
800
|
|
824
801
|
```rb
|
825
802
|
# Gemfile
|
@@ -835,35 +812,15 @@ Rails.application.routes.draw do
|
|
835
812
|
mount Shrine.uppy_s3_multipart(:cache) => "/s3/multipart"
|
836
813
|
end
|
837
814
|
```
|
838
|
-
```js
|
839
|
-
// upload.js
|
840
|
-
// ...
|
841
|
-
uppy.use(Uppy.AwsS3Multipart, {
|
842
|
-
companionUrl: '/' // uses '/s3/multipart/*' routes
|
843
|
-
})
|
844
|
-
|
845
|
-
uppy.on('upload-success', (file, response) => {
|
846
|
-
const uploadedFileData = JSON.stringify({
|
847
|
-
id: response.uploadURL.match(/\/cache\/([^\?]+)/)[1], // object key without prefix
|
848
|
-
storage: 'cache',
|
849
|
-
metadata: {
|
850
|
-
size: file.size,
|
851
|
-
filename: file.name,
|
852
|
-
mime_type: file.type,
|
853
|
-
}
|
854
|
-
})
|
855
|
-
// ... add this data to your form or submit it to your app ...
|
856
|
-
})
|
857
|
-
```
|
858
815
|
|
859
816
|
See the [uppy-s3_multipart] docs for more details.
|
860
817
|
|
861
818
|
#### Tus protocol
|
862
819
|
|
863
820
|
If you want a more generic approach, you can build your resumable uploads on
|
864
|
-
**[tus]
|
821
|
+
**[tus]** – an open resumable upload protocol. On the server side you can use
|
865
822
|
the [tus-ruby-server] gem, on the client side Uppy's [Tus][uppy tus] plugin,
|
866
|
-
and the [shrine-tus] gem for the glue
|
823
|
+
and the [shrine-tus] gem for the glue.
|
867
824
|
|
868
825
|
```rb
|
869
826
|
# Gemfile
|
@@ -885,31 +842,11 @@ Rails.application.routes.draw do
|
|
885
842
|
mount Tus::Server => "/files"
|
886
843
|
end
|
887
844
|
```
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
chunkSize: 5*1024*1024,
|
894
|
-
})
|
895
|
-
|
896
|
-
uppy.on('upload-success', (file, response) => {
|
897
|
-
const uploadedFileData = JSON.stringify({
|
898
|
-
id: response.uploadURL,
|
899
|
-
storage: "cache",
|
900
|
-
metadata: {
|
901
|
-
filename: file.name,
|
902
|
-
size: file.size,
|
903
|
-
mime_type: file.type,
|
904
|
-
}
|
905
|
-
})
|
906
|
-
// ... add this data to your form or submit it to your app ...
|
907
|
-
})
|
908
|
-
```
|
909
|
-
|
910
|
-
For adding tus-powered resumable uploads from scratch, see [this
|
911
|
-
walkthrough][Adding Resumable Uploads] (there is also a [demo app][resumable
|
912
|
-
demo]). See also [shrine-tus] and [tus-ruby-server] docs for more details.
|
845
|
+
|
846
|
+
See [this walkthrough][Adding Resumable Uploads] for adding tus-powered
|
847
|
+
resumable uploads from scratch, it includes a complete JavaScript example
|
848
|
+
(there is also a [demo app][resumable demo]). See also [shrine-tus] and
|
849
|
+
[tus-ruby-server] docs for more details.
|
913
850
|
|
914
851
|
## Backgrounding
|
915
852
|
|
@@ -946,13 +883,13 @@ Shrine doesn't automatically delete files uploaded to temporary storage, instead
|
|
946
883
|
you should set up a separate recurring task that will automatically delete old
|
947
884
|
cached files.
|
948
885
|
|
949
|
-
Most
|
950
|
-
|
886
|
+
Most Shrine storage classes come with a `#clear!` method, which you can call in
|
887
|
+
a recurring script. For FileSystem and S3 storage it would look like this:
|
951
888
|
|
952
889
|
```rb
|
953
890
|
# FileSystem storage
|
954
891
|
file_system = Shrine.storages[:cache]
|
955
|
-
file_system.clear!
|
892
|
+
file_system.clear! { |path| path.mtime < Time.now - 7*24*60*60 } # delete files older than 1 week
|
956
893
|
```
|
957
894
|
```rb
|
958
895
|
# S3 storage
|
@@ -960,27 +897,48 @@ s3 = Shrine.storages[:cache]
|
|
960
897
|
s3.clear! { |object| object.last_modified < Time.now - 7*24*60*60 } # delete files older than 1 week
|
961
898
|
```
|
962
899
|
|
963
|
-
##
|
900
|
+
## Logging
|
964
901
|
|
965
|
-
|
966
|
-
|
967
|
-
convenient.
|
902
|
+
The [`instrumentation`][instrumentation plugin] plugin sends and logs events for
|
903
|
+
important operations:
|
968
904
|
|
969
905
|
```rb
|
970
|
-
Shrine.
|
971
|
-
|
972
|
-
class DocumentUploader < Shrine; end
|
973
|
-
class ImageUploader < Shrine
|
974
|
-
opts[:type] = "image"
|
975
|
-
end
|
906
|
+
Shrine.plugin :instrumentation, notifications: ActiveSupport::Notifications
|
976
907
|
|
977
|
-
|
978
|
-
|
908
|
+
uploaded_file = Shrine.upload(io, :store)
|
909
|
+
uploaded_file.exists?
|
910
|
+
uploaded_file.download
|
911
|
+
uploaded_file.delete
|
912
|
+
```
|
913
|
+
```
|
914
|
+
Metadata (32ms) – {:storage=>:store, :io=>StringIO, :uploader=>Shrine}
|
915
|
+
Upload (1523ms) – {:storage=>:store, :location=>"ed0e30ddec8b97813f2c1f4cfd1700b4", :io=>StringIO, :upload_options=>{}, :uploader=>Shrine}
|
916
|
+
Exists (755ms) – {:storage=>:store, :location=>"ed0e30ddec8b97813f2c1f4cfd1700b4", :uploader=>Shrine}
|
917
|
+
Download (1002ms) – {:storage=>:store, :location=>"ed0e30ddec8b97813f2c1f4cfd1700b4", :download_options=>{}, :uploader=>Shrine}
|
918
|
+
Delete (700ms) – {:storage=>:store, :location=>"ed0e30ddec8b97813f2c1f4cfd1700b4", :uploader=>Shrine}
|
979
919
|
```
|
980
920
|
|
981
|
-
|
982
|
-
|
983
|
-
|
921
|
+
Some plugins add their own instrumentation as well when they detect that the
|
922
|
+
`instrumentation` plugin has been loaded. For that to work, the
|
923
|
+
`instrumentation` plugin needs to be loaded *before* any of these plugins.
|
924
|
+
|
925
|
+
| Plugin | Instrumentation |
|
926
|
+
| :----- | :-------------- |
|
927
|
+
| `derivation_endpoint` | instruments file processing |
|
928
|
+
| `determine_mime_type` | instruments analyzing MIME type |
|
929
|
+
| `store_dimensions` | instruments extracting image dimensions |
|
930
|
+
| `signature` | instruments calculating signature |
|
931
|
+
| `infer_extension` | instruments inferring extension |
|
932
|
+
| `remote_url` | instruments remote URL downloading |
|
933
|
+
| `data_uri` | instruments data URI parsing |
|
934
|
+
|
935
|
+
For instrumentation, warnings, and other logging, Shrine uses its internal
|
936
|
+
logger. You can tell Shrine to use a different logger, for example if you're
|
937
|
+
using Rails:
|
938
|
+
|
939
|
+
```rb
|
940
|
+
Shrine.logger = Rails.logger
|
941
|
+
```
|
984
942
|
|
985
943
|
## Inspiration
|
986
944
|
|
@@ -1081,6 +1039,7 @@ The gem is available as open source under the terms of the [MIT License].
|
|
1081
1039
|
[backgrounding plugin]: /doc/plugins/backgrounding.md#readme
|
1082
1040
|
[derivation_endpoint plugin]: /doc/plugins/derivation_endpoint.md#readme
|
1083
1041
|
[determine_mime_type plugin]: /doc/plugins/determine_mime_type.md#readme
|
1042
|
+
[instrumentation plugin]: /doc/plugins/instrumentation.md#readme
|
1084
1043
|
[hanami plugin]: https://github.com/katafrakt/hanami-shrine
|
1085
1044
|
[mongoid plugin]: https://github.com/shrinerb/shrine-mongoid
|
1086
1045
|
[presign_endpoint plugin]: /doc/plugins/presign_endpoint.md#readme
|
data/doc/advantages.md
CHANGED
@@ -69,12 +69,12 @@ that you want. Moreover, you're only loading the code for features that you
|
|
69
69
|
use, which means that Shrine will generally load very fast.
|
70
70
|
|
71
71
|
```rb
|
72
|
-
Shrine.plugin :
|
72
|
+
Shrine.plugin :instrumentation
|
73
73
|
|
74
74
|
# translates to
|
75
75
|
|
76
|
-
require "shrine/plugins/
|
77
|
-
Shrine.plugin Shrine::Plugins::
|
76
|
+
require "shrine/plugins/instrumentation"
|
77
|
+
Shrine.plugin Shrine::Plugins::Instrumentation
|
78
78
|
```
|
79
79
|
|
80
80
|
Shrine comes with a complete attachment functionality, but it also exposes many
|
@@ -135,7 +135,7 @@ other plugins would be loaded only for a specific uploader.
|
|
135
135
|
|
136
136
|
```rb
|
137
137
|
Shrine.plugin :activerecord
|
138
|
-
Shrine.plugin :
|
138
|
+
Shrine.plugin :instrumentation
|
139
139
|
```
|
140
140
|
```rb
|
141
141
|
class ImageUploader < Shrine
|