dragonfly-azure_data_store 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile.lock +3 -3
- data/README.md +2 -0
- data/lib/dragonfly/azure_data_store.rb +27 -7
- data/lib/dragonfly/azure_data_store/version.rb +1 -1
- metadata +2 -4
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f68fbd5536bb5c88abb5e1d464072a9460a9cd3b
|
4
|
+
data.tar.gz: 32cc8d4759f109a885883a31a5629ee2954ee8b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebac1d185ed46037a940f0b589241fff93171b8e3c89ee949db9b2e482473c57e3d745021a4a342fef3e30672f95334208b34f6a394607878e4cfc628c939d41
|
7
|
+
data.tar.gz: 565a6dc9c05b92ccc6590d49c93788853e0290a52bec86cdc6ed246381ce403bd6fbe1985102e584f918fa17bceb9396b248ee0d0019e36bd98eb4213c68ed2e
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dragonfly-azure_data_store (0.
|
4
|
+
dragonfly-azure_data_store (0.1.1)
|
5
5
|
azure-storage-blob (~> 1.0)
|
6
6
|
dragonfly (~> 1.0)
|
7
7
|
|
@@ -96,8 +96,8 @@ PLATFORMS
|
|
96
96
|
|
97
97
|
DEPENDENCIES
|
98
98
|
dragonfly-azure_data_store!
|
99
|
-
guard-rspec
|
100
|
-
pry-byebug
|
99
|
+
guard-rspec (~> 4.0)
|
100
|
+
pry-byebug (~> 3.0)
|
101
101
|
rspec (~> 3.0)
|
102
102
|
|
103
103
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -36,6 +36,8 @@ end
|
|
36
36
|
:url_scheme # defaults to "http"
|
37
37
|
:url_host # defaults to "<account_name>.blob.core.windows.net"
|
38
38
|
:root_path # store all content under a subdirectory - uids will be relative to this - defaults to nil
|
39
|
+
:store_meta # store metadata info in azure. Defaults to true
|
40
|
+
:legacy_meta # activate only if file store was used before and want to load old `.meta.yml` generated files from azure storage.
|
39
41
|
```
|
40
42
|
|
41
43
|
### Serving directly from Azure
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'dragonfly'
|
2
2
|
require 'azure/storage/blob'
|
3
|
+
require 'yaml'
|
3
4
|
|
4
5
|
Dragonfly::App.register_datastore(:azure) { Dragonfly::AzureDataStore }
|
5
6
|
|
6
7
|
module Dragonfly
|
7
8
|
class AzureDataStore
|
8
9
|
attr_accessor :account_name, :access_key, :container_name, :root_path,
|
9
|
-
:url_scheme, :url_host
|
10
|
+
:url_scheme, :url_host, :store_meta, :legacy_meta
|
10
11
|
|
11
12
|
def initialize(opts = {})
|
12
13
|
@account_name = opts[:account_name]
|
@@ -15,22 +16,37 @@ module Dragonfly
|
|
15
16
|
@root_path = opts[:root_path]
|
16
17
|
@url_scheme = opts[:url_scheme] || 'http'
|
17
18
|
@url_host = opts[:url_host]
|
19
|
+
@store_meta = opts[:store_meta].nil? ? true : opts[:store_meta]
|
20
|
+
@legacy_meta = opts[:legacy_meta]
|
18
21
|
end
|
19
22
|
|
20
23
|
def write(content, _opts = {})
|
21
|
-
blob = nil
|
22
24
|
filename = path_for(content.name || 'file')
|
25
|
+
path = full_path(filename)
|
26
|
+
options = {}
|
27
|
+
options[:metadata] = content.meta if store_meta
|
23
28
|
content.file do |f|
|
24
|
-
|
25
|
-
container.name, full_path(filename), f
|
26
|
-
)
|
29
|
+
storage.create_block_blob(container.name, path, f, options)
|
27
30
|
end
|
28
31
|
filename
|
29
32
|
end
|
30
33
|
|
31
34
|
def read(uid)
|
32
|
-
|
33
|
-
|
35
|
+
path = full_path(uid)
|
36
|
+
blob = storage.get_blob(container.name, path)
|
37
|
+
meta = nil
|
38
|
+
if store_meta
|
39
|
+
meta = blob[0].metadata
|
40
|
+
if legacy_meta && (meta.nil? || meta.empty?)
|
41
|
+
begin
|
42
|
+
meta_blob = storage.get_blob(container.name, meta_path(path))
|
43
|
+
meta = YAML.safe_load(meta_blob[1])
|
44
|
+
rescue Azure::Core::Http::HTTPError
|
45
|
+
meta = {}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
[blob[1], meta]
|
34
50
|
rescue Azure::Core::Http::HTTPError
|
35
51
|
nil
|
36
52
|
end
|
@@ -76,5 +92,9 @@ module Dragonfly
|
|
76
92
|
def full_path(filename)
|
77
93
|
File.join(*[root_path, filename].compact)
|
78
94
|
end
|
95
|
+
|
96
|
+
def meta_path(path)
|
97
|
+
"#{path}.meta.yml"
|
98
|
+
end
|
79
99
|
end
|
80
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragonfly-azure_data_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alter Lagos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: azure-storage-blob
|
@@ -97,8 +97,6 @@ files:
|
|
97
97
|
- LICENSE.txt
|
98
98
|
- README.md
|
99
99
|
- Rakefile
|
100
|
-
- bin/console
|
101
|
-
- bin/setup
|
102
100
|
- dragonfly-azure_data_store.gemspec
|
103
101
|
- lib/dragonfly/azure_data_store.rb
|
104
102
|
- lib/dragonfly/azure_data_store/version.rb
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "dragonfly/azure_data_store"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|