rabbit_swift 0.0.10 → 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/Gemfile +2 -0
- data/lib/rabbit_swift/client.rb +13 -5
- data/lib/rabbit_swift/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: 9a931fba1da7d6d3395b7d1ba340e42f32d4c965
|
4
|
+
data.tar.gz: c3c3429f8a926f5ac06573ca881054fab6abe416
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee1d0ea09abf06eb4bbd3ae093fbde449508a40164120bc3caade604183cec73cd9702228c011deffa48fc76da9c10f98a0a74159a18d3667ba3f672b35a716c
|
7
|
+
data.tar.gz: 1906a96b09bef23f71cfc26a3b4623cb0bd9a3dc980280488c6e3525e584f12c851179d5132b8df7c32ccab3658aaa28a17f1bfa06bf2f96251044706f1b4723
|
data/Gemfile
CHANGED
data/lib/rabbit_swift/client.rb
CHANGED
@@ -3,6 +3,7 @@ require 'uri'
|
|
3
3
|
require 'json'
|
4
4
|
require 'httpclient'
|
5
5
|
require 'pathname'
|
6
|
+
require 'mime/types'
|
6
7
|
|
7
8
|
module RabbitSwift
|
8
9
|
|
@@ -33,13 +34,14 @@ module RabbitSwift
|
|
33
34
|
|
34
35
|
# curl -i -X PUT -H "X-Auth-Token: トークン" オブジェクトストレージエンドポイント/コンテナ名/ -T オブジェクトへのパス
|
35
36
|
def upload(token, end_point, input_file_path)
|
36
|
-
auth_header = {
|
37
|
-
'X-Auth-Token' => token
|
38
|
-
}
|
39
|
-
auth_header['X-Web-Mode'] = 'true' if @web_mode
|
40
37
|
#相対パスがきた時のために絶対パスに変換
|
41
38
|
path_name_obj = Pathname.new(input_file_path);
|
42
39
|
file_path = path_name_obj.expand_path.to_s
|
40
|
+
auth_header = {
|
41
|
+
'X-Auth-Token' => token,
|
42
|
+
'Content-Type' => MIME::Types.type_for(file_path)[0].to_s
|
43
|
+
}
|
44
|
+
auth_header['X-Web-Mode'] = 'true' if @web_mode
|
43
45
|
|
44
46
|
http_client = HTTPClient.new
|
45
47
|
http_client.send_timeout = @send_timeout.to_i unless(@send_timeout.nil?)
|
@@ -49,9 +51,14 @@ module RabbitSwift
|
|
49
51
|
puts 'upload_url -> ' + target_url
|
50
52
|
|
51
53
|
if File::ftype(file_path) == 'directory'
|
52
|
-
auth_header['Content-Type'] = 'application/directory'
|
53
54
|
auth_header['Content-Length'] = 0
|
55
|
+
if @web_mode
|
56
|
+
auth_header['X-Container-Read'] = '.r:*,.rlistings'
|
57
|
+
auth_header['X-Container-Meta-Web-Listings-CSS'] = 'listing.css'
|
58
|
+
end
|
59
|
+
|
54
60
|
@res = http_client.put(URI.parse(URI.encode(target_url)), file_path, auth_header)
|
61
|
+
p @res
|
55
62
|
if @res.status == UPLOAD_SUCCESS_HTTP_STATUS_CODE
|
56
63
|
Dir::foreach(file_path) {|f|
|
57
64
|
next if (f == '.' || f == '..')
|
@@ -66,6 +73,7 @@ module RabbitSwift
|
|
66
73
|
end
|
67
74
|
else
|
68
75
|
File.open(file_path) do |file|
|
76
|
+
p auth_header
|
69
77
|
@res = http_client.put(URI.parse(URI.encode(target_url)), file, auth_header)
|
70
78
|
end
|
71
79
|
end
|
data/lib/rabbit_swift/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbit_swift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AKB428
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|