naranya_ecm-sdk 0.0.39 → 0.0.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/naranya_ecm-sdk/version.rb +1 -1
- data/lib/naranya_ecm/models/media_resource.rb +30 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb12b9f96be85891c4bdb771336a1188f8d97d40
|
4
|
+
data.tar.gz: 680268da4b3ed590de625d32aee26d76a52764ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 293bf2f5660427115469ce31089a7e82684ff5faccc25cba3fc5d5ef0fe157cfd67714dc1ab3c8d3efafb3868ec9776ebe42c4d1cfb3fcd4eb9c78c54ba8738f
|
7
|
+
data.tar.gz: 485b330b2cd103747136533252496f2284e37859971765386bec2be9a4cf0a4b3a3e2f2d5b7ae1f232e4aca182737a26ca3ec7e858748a19858eec1feacfc9ca
|
@@ -18,7 +18,7 @@ module NaranyaEcm
|
|
18
18
|
# The access type of the media file (private|public)
|
19
19
|
field :access_type, type: String, default: -> { 'public' }
|
20
20
|
validates :access_type, presence: true
|
21
|
-
|
21
|
+
|
22
22
|
# The list of compatible device ids:
|
23
23
|
field :compatible_device_ids, type: Array, default: -> { [] }
|
24
24
|
|
@@ -47,7 +47,7 @@ module NaranyaEcm
|
|
47
47
|
# Returns the downloadable resource key, which depending of the storage engine, is one of the following:
|
48
48
|
# - Amazon AWS S3: The downloadable object key
|
49
49
|
def downloadable_resource_key
|
50
|
-
@downloadable_file_key ||=
|
50
|
+
@downloadable_file_key ||= self.downloadable_path[1..-1] if self.downloadable_path.present?
|
51
51
|
end
|
52
52
|
|
53
53
|
# Returns the downloadable resource, which depending of the storage engine, is one of the following:
|
@@ -56,6 +56,28 @@ module NaranyaEcm
|
|
56
56
|
root_directory.files.head downloadable_resource_key
|
57
57
|
end
|
58
58
|
|
59
|
+
def downloadable_uri
|
60
|
+
@downloadable_uri ||= URI(self.downloadable_url) if self.downloadable_url.present?
|
61
|
+
end
|
62
|
+
|
63
|
+
def downloadable_path
|
64
|
+
@downloadable_path ||= self.downloadable_uri.path if self.downloadable_uri.present?
|
65
|
+
end
|
66
|
+
|
67
|
+
def downloadable_host
|
68
|
+
@downloadable_host ||= self.downloadable_uri.host if self.downloadable_uri.present?
|
69
|
+
end
|
70
|
+
|
71
|
+
def downloadable_cdn_url(options = {})
|
72
|
+
options = options.with_indifferent_access
|
73
|
+
ret = self.downloadable_uri.clone
|
74
|
+
|
75
|
+
ret.scheme = options[:scheme] if options.has_key? :scheme
|
76
|
+
ret.host = options[:host] if options.has_key? :host
|
77
|
+
|
78
|
+
ret.to_s
|
79
|
+
end
|
80
|
+
|
59
81
|
# Return the URL used to access the media resource file.
|
60
82
|
# - In case of a private resource file, the URL includes parameters used to access the file
|
61
83
|
# for the following 5 minutes, unless an expiration time is given.
|
@@ -81,12 +103,12 @@ module NaranyaEcm
|
|
81
103
|
raise ArgumentError, "Given path is empty" unless path.present?
|
82
104
|
path = path[1..-1] if path.present? && path[0] == "/"
|
83
105
|
raise ArgumentError, "Can't use root (/) as target path" unless path.present?
|
84
|
-
|
106
|
+
|
85
107
|
path_exists = root_directory.files.head(path).present?
|
86
|
-
|
108
|
+
|
87
109
|
if !path_exists || (path_exists && force_move)
|
88
110
|
old_file = root_directory.files.get downloadable_resource_key
|
89
|
-
|
111
|
+
|
90
112
|
new_file = root_directory.files.create(
|
91
113
|
key: path,
|
92
114
|
body: old_file.body,
|
@@ -94,9 +116,9 @@ module NaranyaEcm
|
|
94
116
|
last_modified: old_file.last_modified,
|
95
117
|
:public => public?
|
96
118
|
)
|
97
|
-
|
119
|
+
|
98
120
|
self.downloadable_url = public? ? new_file.public_url : new_file.url(1.minutes.from_now).split("?").first
|
99
|
-
|
121
|
+
|
100
122
|
old_file.destroy if self.save
|
101
123
|
true
|
102
124
|
else
|
@@ -114,6 +136,6 @@ module NaranyaEcm
|
|
114
136
|
|
115
137
|
NaranyaEcm::MediaProcess.create options
|
116
138
|
end
|
117
|
-
|
139
|
+
|
118
140
|
end
|
119
141
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naranya_ecm-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.40
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Quintanilla
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|