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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b42ed9e980fd09c329392326aab8701273a6059
4
- data.tar.gz: ef8f99157a20b4f50410487154b2d53bd838d3eb
3
+ metadata.gz: 9a931fba1da7d6d3395b7d1ba340e42f32d4c965
4
+ data.tar.gz: c3c3429f8a926f5ac06573ca881054fab6abe416
5
5
  SHA512:
6
- metadata.gz: bbe71465ee11813dc788cb4a4cfaa77daecc4407814b070e5b5e9e787c1eaf2feb3c89e95e7b142d80f93c8d76da3ec3c6969a0a39aa023fde61aa9dc80571ef
7
- data.tar.gz: 3c62cf5c6802706ff930863ac4d342af01d253ece14304e31c1c4398b9b3adcb5a19cabbc31b8cac5b5f1a7974cf6a636e90ae22fa9f11a75f0afe17e6cd7d82
6
+ metadata.gz: ee1d0ea09abf06eb4bbd3ae093fbde449508a40164120bc3caade604183cec73cd9702228c011deffa48fc76da9c10f98a0a74159a18d3667ba3f672b35a716c
7
+ data.tar.gz: 1906a96b09bef23f71cfc26a3b4623cb0bd9a3dc980280488c6e3525e584f12c851179d5132b8df7c32ccab3658aaa28a17f1bfa06bf2f96251044706f1b4723
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rabbit_swift.gemspec
4
4
  gemspec
5
+ gem 'httpclient'
6
+ gem 'mime-types'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RabbitSwift
2
- VERSION = "0.0.10"
2
+ VERSION = "0.1.1"
3
3
  end
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.0.10
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-20 00:00:00.000000000 Z
11
+ date: 2014-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler