activestorage-nft 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/active_storage/service/nft_service.rb +1 -7
- data/lib/active_storage/service/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1972440956f424c80c336dac03420a00992c94bdc6daea4a26320d9d01114281
|
4
|
+
data.tar.gz: d5729065c466a6e72b50f9fe837e380ab222f0770399052d8568a6e8f9ade714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f91c7c080cd4c401efd5bf2ad3215b121eabad23d5f67e33fb08d5122f2029259d7a5625f133e62c92ec571d88165ee6d472d5e34f11e8535a8bd1aab5cab990
|
7
|
+
data.tar.gz: 4346b3d021f1c34f730b71ea870becdf1120df6a3b990dd6994ff54cbb2f5056ce5e31c32b917a5e1abf42905762c985716b44015bdd40e9cd7985c874a8a18d
|
data/README.md
CHANGED
@@ -4,7 +4,9 @@ ActiveStorage adapter for [NFT.storage](https://nft.storage).
|
|
4
4
|
|
5
5
|
Uploaded files are automatically pinned on the pinata.cloud IPFS pinning service, courtesey of [Protocol Labs](https://protocol.ai).
|
6
6
|
|
7
|
-
|
7
|
+
## Note on uniqueness
|
8
|
+
|
9
|
+
When uploading a file that already exists (same content hash), an `ActiveRecord::RecordNotUnique` exception will be raised.
|
8
10
|
|
9
11
|
## Installation
|
10
12
|
|
@@ -1,9 +1,5 @@
|
|
1
1
|
require 'nft/client'
|
2
2
|
|
3
|
-
class ActiveStorage::Blob
|
4
|
-
validates :key, uniqueness: true
|
5
|
-
end
|
6
|
-
|
7
3
|
module ActiveStorage
|
8
4
|
class Service::NftService < Service
|
9
5
|
attr_accessor :client
|
@@ -18,9 +14,7 @@ module ActiveStorage
|
|
18
14
|
def upload(key, io, checksum: nil, **)
|
19
15
|
instrument :upload, key: key, checksum: checksum do
|
20
16
|
cid_key = @client.add io.path
|
21
|
-
blob = Blob.find_by_key(key)
|
22
|
-
blob.key = cid_key
|
23
|
-
blob.save!
|
17
|
+
blob = Blob.find_by_key(key).update!(key: cid_key)
|
24
18
|
end
|
25
19
|
end
|
26
20
|
|