netstorageapi 0.6.0 → 0.7.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/akamai/netstorage.rb +19 -14
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a509b95dc49d46bc8e5edd21eb5fef487b5d59b
4
- data.tar.gz: 4c2a3a13bedd54f097c660769b0a20e14613f453
3
+ metadata.gz: dc6268c9d0f13d22e3b612b1532270f921f38a25
4
+ data.tar.gz: a4d51f394e0f7a370a00a51d13c903b69971042e
5
5
  SHA512:
6
- metadata.gz: fef8fcf2b93ca511545fc6793c3c563cc27051130fc65b80f7cc2bcbbe9fa7f24206bd21773b096ec255756319d6196fd2437725cf61b077556cce07dccfaf2d
7
- data.tar.gz: 7dfd3048ba4f94eabb87ad7b6d438232ff4355e970fabe9b5e52ba04022632a876d9aab338cf8f6c6087cdcbf0180c857f20c6c87239f52d3abaf603b33be4fc
6
+ metadata.gz: 5fa9b21bcfeee2b9deb1ba475c7c5508aec6602d61af2fd0a306dbcd80822247e10931607a4728f3ffa240803cd7b03c58d7114b26aa01673f03524feb64491b
7
+ data.tar.gz: fa12031d244fb8583870d0b571cd36db0266145f52d9cbb93188f6d160d419f352b846092737c2591d4063fba70f01c7d971f240c4de6fa2d97f978278b99d95
@@ -26,13 +26,15 @@ require "uri"
26
26
 
27
27
  module Akamai
28
28
  class Netstorage
29
- attr_accessor :hostname, :keyname, :key
29
+ attr_accessor :hostname, :keyname, :key, :ssl
30
30
  attr_reader :request
31
31
 
32
- def initialize(hostname, keyname, key)
32
+ def initialize(hostname, keyname, key, ssl=false)
33
33
  @hostname = hostname
34
34
  @keyname = keyname
35
35
  @key = key
36
+ @ssl = ssl ? 's' : ''
37
+
36
38
  @request = nil
37
39
  end
38
40
 
@@ -49,7 +51,8 @@ module Akamai
49
51
  local_destination = File.join(local_destination, ns_filename)
50
52
  end
51
53
  end
52
- response = Net::HTTP.start(uri.hostname, uri.port) { |http|
54
+ response = Net::HTTP.start(uri.hostname, uri.port,
55
+ :use_ssl => uri.scheme == 'https') { |http|
53
56
  http.request @request do |res|
54
57
  open(local_destination, "wb") do |io|
55
58
  res.read_body do |chunk|
@@ -58,16 +61,18 @@ module Akamai
58
61
  end
59
62
  end
60
63
  }
61
- elsif kwargs[:action] == "upload"
62
- @request.body = File.read(kwargs[:source])
63
- response = Net::HTTP.start(uri.hostname, uri.port) { |http|
64
- http.request(@request)
65
- }
66
- else
67
- response = Net::HTTP.start(uri.hostname, uri.port) { |http|
68
- http.request(@request)
69
- }
70
- end
64
+ return response
65
+ end
66
+
67
+ if kwargs[:action] == "upload"
68
+ @request.body = File.read(kwargs[:source])
69
+ end
70
+
71
+ response = Net::HTTP.start(uri.hostname, uri.port,
72
+ :use_ssl => uri.scheme == 'https') { |http|
73
+ http.request(@request)
74
+ }
75
+
71
76
  return response
72
77
  end
73
78
 
@@ -81,7 +86,7 @@ module Akamai
81
86
  hash_ = OpenSSL::HMAC.digest("sha256", @key, message)
82
87
  acs_auth_sign = Base64.encode64(hash_).rstrip
83
88
 
84
- uri = URI("http://#{@hostname}#{path}")
89
+ uri = URI("http#{@ssl}://#{@hostname}#{path}")
85
90
  headers = {
86
91
  'X-Akamai-ACS-Action' => acs_action,
87
92
  'X-Akamai-ACS-Auth-Data' => acs_auth_data,
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.6.0
4
+ version: 0.7.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-08-06 00:00:00.000000000 Z
11
+ date: 2016-09-14 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