digitsend 0.0.12 → 0.0.13
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.
- data/lib/digitsend/client.rb +10 -10
- data/lib/digitsend/repository.rb +30 -6
- data/lib/digitsend/version.rb +1 -1
- metadata +2 -2
data/lib/digitsend/client.rb
CHANGED
@@ -34,6 +34,16 @@ module DigitSend
|
|
34
34
|
response["uuid"]
|
35
35
|
end
|
36
36
|
|
37
|
+
def stream_for_data(path, data)
|
38
|
+
if data.nil?
|
39
|
+
File.open(path, "r")
|
40
|
+
elsif data.is_a?(String)
|
41
|
+
StringIO.new(data)
|
42
|
+
else
|
43
|
+
data
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
37
47
|
private
|
38
48
|
|
39
49
|
def create_s3_file(filename)
|
@@ -54,16 +64,6 @@ module DigitSend
|
|
54
64
|
end
|
55
65
|
end
|
56
66
|
|
57
|
-
def stream_for_data(path, data)
|
58
|
-
if data.nil?
|
59
|
-
File.open(path, "r")
|
60
|
-
elsif data.is_a?(String)
|
61
|
-
StringIO.new(data)
|
62
|
-
else
|
63
|
-
data
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
67
|
def exception_for_response(hash)
|
68
68
|
raise case hash["message"]
|
69
69
|
when "Missing phone numbers" then MissingPhoneNumbers.new(hash)
|
data/lib/digitsend/repository.rb
CHANGED
@@ -1,12 +1,36 @@
|
|
1
1
|
module DigitSend
|
2
2
|
class Repository
|
3
|
-
|
4
|
-
|
3
|
+
class <<self
|
4
|
+
def self.upload(repo_name, path, filename, data = nil)
|
5
|
+
begin
|
6
|
+
uuid = Client.upload_s3_file(filename, data)
|
7
|
+
rescue
|
8
|
+
return create_version_with_s3_file(filename, data)
|
9
|
+
end
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
create_version_with_s3_file(uuid)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def create_version_with_s3_file(uuid)
|
17
|
+
Client.call '/files/versions',
|
18
|
+
repo_name: repo_name,
|
19
|
+
path: path,
|
20
|
+
repo_file_version: {
|
21
|
+
s3_file_uuid: uuid
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_version_with_content(filename, data)
|
26
|
+
Client.call '/files/versions',
|
27
|
+
repo_name: repo_name,
|
28
|
+
path: path,
|
29
|
+
direct_upload: {
|
30
|
+
filename: filename,
|
31
|
+
data: stream_for_data(filename, data).read
|
32
|
+
}
|
33
|
+
end
|
10
34
|
end
|
11
35
|
end
|
12
36
|
end
|
data/lib/digitsend/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digitsend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multipart-post
|