s3_media_server_api 0.1.0.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +27 -0
- data/lib/s3_media_server_api/media.rb +1 -0
- data/lib/s3_media_server_api/media/audio.rb +0 -11
- data/lib/s3_media_server_api/media/collection.rb +5 -9
- data/lib/s3_media_server_api/media/common_media_api.rb +17 -3
- data/lib/s3_media_server_api/media/document.rb +0 -11
- data/lib/s3_media_server_api/media/image.rb +0 -11
- data/lib/s3_media_server_api/media/video.rb +0 -11
- data/lib/s3_media_server_api/mocked/request.rb +29 -1
- data/lib/s3_media_server_api/version.rb +1 -1
- 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: 6fb4b13fe747e3af3990c2d8a08e4c3ccb60766c
|
4
|
+
data.tar.gz: 5ce9e75067d2e47f3a7a3e912e4fa052ef2f4265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5d800aa65a4bd113331b6c1ad922951ba5c2811e9d1e6ded9748171d0f2cb5f7ce8b75837de047cc5fb95a2f31e099db3a56438831dad8e7cedf070085a1cc6
|
7
|
+
data.tar.gz: 084787667184b2363179070f932a1e1983843701cf57e4935093f4e360ab4e0959304ebfd3e97450dabcb7de8908bcf1890b10552b063cb809a2daa50c99cdfb
|
data/README.md
CHANGED
@@ -163,6 +163,33 @@ video.versions[0].size
|
|
163
163
|
S3MediaServerApi::Media::Video.destroy(video.uuid)
|
164
164
|
```
|
165
165
|
|
166
|
+
#### S3MediaServerApi::Media::Collection
|
167
|
+
Use S3MediaServerApi::Media::Collection to interact with Collection resource
|
168
|
+
```ruby
|
169
|
+
# to create Collection, use create method
|
170
|
+
# provide uuid of collection owner
|
171
|
+
owner_uuid = "4edbfdf9-9517-4902-8e92-2212215b0de5"
|
172
|
+
collection = S3MediaServerApi::Media::Collection.create(owner_uuid)
|
173
|
+
|
174
|
+
|
175
|
+
# to resolve document, use resolve method
|
176
|
+
resolved_collection = S3MediaServerApi::Media::Collection.resolve(created_collection.uuid)
|
177
|
+
|
178
|
+
# both methods create and resolve return collection object
|
179
|
+
|
180
|
+
resolved_collection.uuid # uuid of the collection
|
181
|
+
resolved_collection.owner_uuid # uuid of the collection owner
|
182
|
+
resolved_collection.videos # array of videos
|
183
|
+
resolved_collection.documents # array of documents
|
184
|
+
resolved_collection.images # array of images
|
185
|
+
resolved_collection.audios # array of audio files
|
186
|
+
# NOTE: video, document, image and audio objects are described above
|
187
|
+
|
188
|
+
# use destroy method, to destroy collection
|
189
|
+
# this method is asynchronous, so it doesn't return anything
|
190
|
+
S3MediaServerApi::Media::Colllection.destroy(created_collection.uuid)
|
191
|
+
```
|
192
|
+
|
166
193
|
#### AwsFile
|
167
194
|
```ruby
|
168
195
|
# to create aws file from its path, use upload method from S3MediaServerApi::Uploader module
|
@@ -20,17 +20,6 @@ module S3MediaServerApi
|
|
20
20
|
end
|
21
21
|
|
22
22
|
class << self
|
23
|
-
def create(uuid)
|
24
|
-
Audio.new(super(uuid))
|
25
|
-
end
|
26
|
-
|
27
|
-
def create_from_path(path)
|
28
|
-
Audio.new(super(path))
|
29
|
-
end
|
30
|
-
|
31
|
-
def resolve(uuid)
|
32
|
-
Audio.new(super(uuid))
|
33
|
-
end
|
34
23
|
#
|
35
24
|
# sends request to cut audio file
|
36
25
|
# parameters: uuid - uuid of file
|
@@ -1,22 +1,22 @@
|
|
1
1
|
module S3MediaServerApi
|
2
2
|
module Media
|
3
|
-
class
|
3
|
+
class Collection < CommonMediaApi
|
4
4
|
COLLECTION = 'collection'
|
5
5
|
|
6
6
|
def videos
|
7
|
-
@params[:videos].map { |video| Video.new(video) } if @params[:videos]
|
7
|
+
@params[:videos].map { |video| Video.new(data: video) } if @params[:videos]
|
8
8
|
end
|
9
9
|
|
10
10
|
def images
|
11
|
-
@params[:images].map { |image| Image::ImageObject.new(image) } if @params[:images]
|
11
|
+
@params[:images].map { |image| Image::ImageObject.new(data: image) } if @params[:images]
|
12
12
|
end
|
13
13
|
|
14
14
|
def documents
|
15
|
-
@params[:documents].map { |
|
15
|
+
@params[:documents].map { |document| Video.new(data: document) } if @params[:documents]
|
16
16
|
end
|
17
17
|
|
18
18
|
def audios
|
19
|
-
@params[:audios].map { |
|
19
|
+
@params[:audios].map { |audio| Audio.new(data: audio) } if @params[:audios]
|
20
20
|
end
|
21
21
|
|
22
22
|
def owner_uuid
|
@@ -25,10 +25,6 @@ module S3MediaServerApi
|
|
25
25
|
|
26
26
|
class << self
|
27
27
|
|
28
|
-
def resolve(uuid)
|
29
|
-
Collection.new(super(uuid))
|
30
|
-
end
|
31
|
-
|
32
28
|
private
|
33
29
|
|
34
30
|
def media_type; COLLECTION; end
|
@@ -35,10 +35,20 @@ module S3MediaServerApi
|
|
35
35
|
|
36
36
|
class << self
|
37
37
|
def create(uuid)
|
38
|
-
params =
|
38
|
+
params = {}
|
39
|
+
case media_type
|
40
|
+
when 'video'
|
41
|
+
params = {uuid: uuid}
|
42
|
+
when 'collection'
|
43
|
+
params = {owner_uuid: uuid}
|
44
|
+
else
|
45
|
+
params = { aws_file_uuid: uuid }
|
46
|
+
end
|
47
|
+
return empty_object unless uuid
|
48
|
+
|
39
49
|
response = AsynkRequest.sync_request(base_path, :create, params)
|
40
50
|
raise CreationError.message_from_asynk_response(response) unless response.success?
|
41
|
-
response
|
51
|
+
self.new(response)
|
42
52
|
end
|
43
53
|
#
|
44
54
|
# creates media file
|
@@ -65,9 +75,10 @@ module S3MediaServerApi
|
|
65
75
|
# returns: response with file information
|
66
76
|
#
|
67
77
|
def resolve(uuid)
|
78
|
+
return empty_object unless uuid
|
68
79
|
cache_key = "#{media_type}/#{uuid}"
|
69
80
|
Config.cache_class.fetch(cache_key) do
|
70
|
-
AsynkRequest.sync_request(base_path, :resolve, uuid: uuid)
|
81
|
+
self.new(AsynkRequest.sync_request(base_path, :resolve, uuid: uuid))
|
71
82
|
end
|
72
83
|
end
|
73
84
|
#
|
@@ -94,6 +105,9 @@ module S3MediaServerApi
|
|
94
105
|
end
|
95
106
|
|
96
107
|
private
|
108
|
+
def empty_object
|
109
|
+
self.new(data: nil)
|
110
|
+
end
|
97
111
|
#
|
98
112
|
# specifies media type which methods will be called
|
99
113
|
#
|
@@ -8,17 +8,6 @@ module S3MediaServerApi
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class << self
|
11
|
-
def create(uuid)
|
12
|
-
Document.new(super(uuid))
|
13
|
-
end
|
14
|
-
|
15
|
-
def create_from_path(path)
|
16
|
-
Document.new(super(path))
|
17
|
-
end
|
18
|
-
|
19
|
-
def resolve(uuid)
|
20
|
-
Document.new(super(uuid))
|
21
|
-
end
|
22
11
|
|
23
12
|
private
|
24
13
|
|
@@ -35,17 +35,6 @@ module S3MediaServerApi
|
|
35
35
|
end
|
36
36
|
|
37
37
|
class << self
|
38
|
-
def create(uuid)
|
39
|
-
Image.new(super(uuid))
|
40
|
-
end
|
41
|
-
|
42
|
-
def create_from_path(path)
|
43
|
-
Image.new(super(path))
|
44
|
-
end
|
45
|
-
|
46
|
-
def resolve(uuid)
|
47
|
-
Image.new(super(uuid))
|
48
|
-
end
|
49
38
|
#
|
50
39
|
# copies image file
|
51
40
|
# parameters: uuid - uuid of file
|
@@ -54,17 +54,6 @@ module S3MediaServerApi
|
|
54
54
|
end
|
55
55
|
|
56
56
|
class << self
|
57
|
-
def create(uuid)
|
58
|
-
Video.new(super(uuid))
|
59
|
-
end
|
60
|
-
|
61
|
-
def create_from_path(path)
|
62
|
-
Video.new(super(path))
|
63
|
-
end
|
64
|
-
|
65
|
-
def resolve(uuid)
|
66
|
-
Video.new(super(uuid))
|
67
|
-
end
|
68
57
|
|
69
58
|
private
|
70
59
|
|
@@ -25,6 +25,8 @@ module S3MediaServerApi
|
|
25
25
|
mocked_image_sync_request(params)
|
26
26
|
when /s3_media_server.media.(document).(\.*)/
|
27
27
|
mocked_document_sync_request(params)
|
28
|
+
when /s3_media_server.media.(collection).(\.*)/
|
29
|
+
mocked_collection_sync_request(params)
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
@@ -49,9 +51,10 @@ module S3MediaServerApi
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def mocked_video_sync_request(params)
|
54
|
+
uuid = params[:aws_file_uuid] ? params[:aws_file_uuid] : params[:uuid]
|
52
55
|
response = {:data=>{:duration=>6.037,
|
53
56
|
:transcoded=>true,
|
54
|
-
:uuid=>
|
57
|
+
:uuid=>uuid,
|
55
58
|
:versions=>[{ :url=>"https://storage-nginx.stage.govermedia.com/test-bucket/test_files/18e776ab-c4ca-40cd-9ecb-a605664ce118.mp4",
|
56
59
|
:format=>"mp4",
|
57
60
|
:size=>326089,
|
@@ -139,6 +142,31 @@ module S3MediaServerApi
|
|
139
142
|
name: "document.pdf"}}
|
140
143
|
Request.new(response)
|
141
144
|
end
|
145
|
+
|
146
|
+
def mocked_collection_sync_request(params)
|
147
|
+
response = {:data=>{:videos=>[{:duration=>104.50999999999999,
|
148
|
+
:transcoded=>true,
|
149
|
+
:uuid=>"597e7538-3455-4ec2-b234-0cc4bc6c4870",
|
150
|
+
:versions=>[{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/ccbb152c-328b-4f2d-bc09-aefc16416698.mp4", :format=>"mp4", :size=>12300035, :resolution=>"r480p"}, {:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/e2de9962-99da-4d4e-8eb8-80d6d38e2526.mp4", :format=>"mp4", :size=>5796575, :resolution=>"r240p"}, {:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/7773219c-feb4-43cf-927a-7b63d5638884.mp4", :format=>"mp4", :size=>9447976, :resolution=>"r360p"}, {:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/cf52bc8a-976c-453d-9208-f998e014e9c4.webm", :format=>"webm", :size=>4079234, :resolution=>"r240p"}, {:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/b5f5555c-9358-46b4-92fd-07a1fc06cc25.mp4", :format=>"mp4", :size=>29609393, :resolution=>"r720p"}, {:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/c27ee433-c380-48ae-9507-23fccac2d115.webm", :format=>"webm", :size=>11323327, :resolution=>"r480p"}, {:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/ed96c629-0ca8-4a07-ab30-81ff085b8560.webm", :format=>"webm", :size=>21693633, :resolution=>"r720p"}, {:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/644ba3fb-cc25-46fb-8e80-3a58a6554648.webm", :format=>"webm", :size=>8039883, :resolution=>"r360p"}],
|
151
|
+
:preview=>{:uuid=>"1e271fe0-5645-4ce2-bcdc-db0f93cf26d7", :size=>68287, :name=>nil, :source=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/5f30a9f3-b9a3-4b2f-8fac-86cb2c128def.jpeg", :width=>1280, :height=>720}, :thumb=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/0ab76f9d-4633-4e24-9937-d0a7ebad5359.jpeg", :width=>nil, :height=>nil}},
|
152
|
+
:screenshots=>[{:uuid=>"d96fc060-ccd0-4ce1-86f8-af11f59b82fb", :size=>68448, :name=>nil, :source=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/d2b24e87-5aee-4180-90b0-d80276ea9843.jpeg", :width=>1280, :height=>720}, :thumb=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/de3bf8ec-18c2-4039-823e-0f12ae9bed55.jpeg", :width=>nil, :height=>nil}}, {:uuid=>"1e271fe0-5645-4ce2-bcdc-db0f93cf26d7", :size=>68287, :name=>nil, :source=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/5f30a9f3-b9a3-4b2f-8fac-86cb2c128def.jpeg", :width=>1280, :height=>720}, :thumb=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/0ab76f9d-4633-4e24-9937-d0a7ebad5359.jpeg", :width=>nil, :height=>nil}}, {:uuid=>"ce174591-d297-43da-9cbd-00056f22dc29", :size=>64795, :name=>nil, :source=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/0f364891-37ae-4acd-b89f-e93ccbf9fd9d.jpeg", :width=>1280, :height=>720}, :thumb=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/b7094c5c-ae8b-447d-844b-00c3acbf4333.jpeg", :width=>440, :height=>248}}], :name=>"2c6d87a9-1d81-48e5-9282-81a76f1e942d.mp4", :embed_url=>"https://stage.govermedia.com/embed_video/?uuid=597e7538-3455-4ec2-b234-0cc4bc6c4870", :provider=>"govermedia"}],
|
153
|
+
:audios=>[{ url: "https://storage-nginx.stage.govermedia.com/test-bucket/test_files/#{SecureRandom.uuid}.mp3",
|
154
|
+
sample_url: "https://storage-nginx.stage.govermedia.com/test-bucket/test_files/#{SecureRandom.uuid}.mp3",
|
155
|
+
uuid: 'asfasfasfasfasf',
|
156
|
+
size: 704512,
|
157
|
+
sample_uploaded: true,
|
158
|
+
name: "music_test.mp3",
|
159
|
+
duration: 87.891875,
|
160
|
+
sample_duration: 19.983673}],
|
161
|
+
:documents=>[{url: "https://storage-nginx.stage.govermedia.com/test-bucket/test_files/95d5edfe-1f17-422d-85c7-69f63e00c3fe.mp4",
|
162
|
+
uuid: "c147f0aa-f0e3-42da-ab0e-28895dc21ea1",
|
163
|
+
size: 245779,
|
164
|
+
name: "document.pdf"}],
|
165
|
+
:images=>[{:uuid=>"ccfac9dc-e208-4644-b932-18e1aae95f4f", :size=>312857, :name=>'image1.jpeg', :source=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/23b3d879-bc0c-47a1-aba5-2fcc20ee6872.png", :width=>600, :height=>437}, :thumb=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/589ea98b-1c90-46e4-a98f-0e42798a549c.jpeg", :width=>384, :height=>280}}, {:uuid=>"c1e43b8d-e593-466d-8aa1-0fdd56282052", :size=>83782, :name=>nil, :source=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/34ee64a7-bf47-4d47-8dc2-c3d8ae522087.png", :width=>836, :height=>546}, :thumb=>{:url=>"https://storage-nginx.stage.govermedia.com/gm-s2-f/files/89847cd4-4e88-4373-af53-54ad3d52fbdd.jpeg", :width=>429, :height=>280}}],
|
166
|
+
:uuid=>params[:uuid],
|
167
|
+
:owner_uuid=>"ee287478-d4d7-4731-a11e-d18cf8cfd1c5"}}
|
168
|
+
Request.new(response)
|
169
|
+
end
|
142
170
|
end
|
143
171
|
end
|
144
172
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_media_server_api
|
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
|
- Ayrat Badykov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|