netstorageapi 0.5.0 → 0.6.0
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/lib/akamai/netstorage.rb +11 -10
- 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: 7a509b95dc49d46bc8e5edd21eb5fef487b5d59b
|
4
|
+
data.tar.gz: 4c2a3a13bedd54f097c660769b0a20e14613f453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fef8fcf2b93ca511545fc6793c3c563cc27051130fc65b80f7cc2bcbbe9fa7f24206bd21773b096ec255756319d6196fd2437725cf61b077556cce07dccfaf2d
|
7
|
+
data.tar.gz: 7dfd3048ba4f94eabb87ad7b6d438232ff4355e970fabe9b5e52ba04022632a876d9aab338cf8f6c6087cdcbf0180c857f20c6c87239f52d3abaf603b33be4fc
|
data/lib/akamai/netstorage.rb
CHANGED
@@ -26,18 +26,19 @@ require "uri"
|
|
26
26
|
|
27
27
|
module Akamai
|
28
28
|
class Netstorage
|
29
|
-
|
30
29
|
attr_accessor :hostname, :keyname, :key
|
30
|
+
attr_reader :request
|
31
31
|
|
32
32
|
def initialize(hostname, keyname, key)
|
33
33
|
@hostname = hostname
|
34
34
|
@keyname = keyname
|
35
35
|
@key = key
|
36
|
+
@request = nil
|
36
37
|
end
|
37
38
|
|
38
39
|
private
|
39
40
|
|
40
|
-
def _response(
|
41
|
+
def _response(uri, kwargs)
|
41
42
|
if kwargs[:action] == "download"
|
42
43
|
local_destination = kwargs[:destination]
|
43
44
|
if kwargs[:path]
|
@@ -49,7 +50,7 @@ module Akamai
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
response = Net::HTTP.start(uri.hostname, uri.port) { |http|
|
52
|
-
http.request request do |res|
|
53
|
+
http.request @request do |res|
|
53
54
|
open(local_destination, "wb") do |io|
|
54
55
|
res.read_body do |chunk|
|
55
56
|
io.write chunk
|
@@ -58,13 +59,13 @@ module Akamai
|
|
58
59
|
end
|
59
60
|
}
|
60
61
|
elsif kwargs[:action] == "upload"
|
61
|
-
request.body = File.read(kwargs[:source])
|
62
|
+
@request.body = File.read(kwargs[:source])
|
62
63
|
response = Net::HTTP.start(uri.hostname, uri.port) { |http|
|
63
|
-
http.request(request)
|
64
|
+
http.request(@request)
|
64
65
|
}
|
65
66
|
else
|
66
67
|
response = Net::HTTP.start(uri.hostname, uri.port) { |http|
|
67
|
-
http.request(request)
|
68
|
+
http.request(@request)
|
68
69
|
}
|
69
70
|
end
|
70
71
|
return response
|
@@ -89,14 +90,14 @@ module Akamai
|
|
89
90
|
}
|
90
91
|
|
91
92
|
if kwargs[:method] == "GET"
|
92
|
-
request = Net::HTTP::Get.new(uri, initheader=headers)
|
93
|
+
@request = Net::HTTP::Get.new(uri, initheader=headers)
|
93
94
|
elsif kwargs[:method] == "POST"
|
94
|
-
request = Net::HTTP::Post.new(uri, initheader=headers)
|
95
|
+
@request = Net::HTTP::Post.new(uri, initheader=headers)
|
95
96
|
elsif kwargs[:method] == "PUT" # Use only upload
|
96
|
-
request = Net::HTTP::Put.new(uri, initheader=headers)
|
97
|
+
@request = Net::HTTP::Put.new(uri, initheader=headers)
|
97
98
|
end
|
98
99
|
|
99
|
-
response = _response(
|
100
|
+
response = _response(uri, kwargs)
|
100
101
|
|
101
102
|
return response.code == "200", response
|
102
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netstorageapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Astin Choi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: NetstorageAPI is Akamai Netstorage (File/Object Store) API for Ruby 2.0+
|
14
14
|
email: achoi@akamai.com
|