sharefile_connect 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c8c189c1d7ea9716956665ff4d7fd8e20540873
4
- data.tar.gz: 2d89993887add8a3c7ebc873bd683f99aed831e1
3
+ metadata.gz: 2525f795b89b4786db578dc2f9d683a71294dc32
4
+ data.tar.gz: a7f28ebc7f513c3da51a5c270dfd9ecf99330bac
5
5
  SHA512:
6
- metadata.gz: 09a97f3a62411a4e5f0a8d66869f5c63f854219a8765484fd64f977ba04d13a201a37cca56d39f413491aaca8fa201e04f282d0ecffba520031955188a3da870
7
- data.tar.gz: d51bf175514dbaf13498e6b1fdcd566f08410ddf4dbdfd7d5c0fcd9ae230864154ffb93083304091ce4efb72632090c3d8510317ba0d84784976a2d4291d4fb3
6
+ metadata.gz: 83470fe81aaab07117daa49d58417c40673678b6dcbb5e579c2721f2738eeef997cc37322d84a9c8e0648f106394aed3649f6f1c9301a96bdffd21c17cefecaa
7
+ data.tar.gz: cc3699bbc5a94c1f76c5b930ef0b07b241891e9ec4c2fbe566ef0c84048994312d68a7fb3b50bfca517722a666cd6b8d242d28c7433fd90806dfcf805bb2a37a
@@ -0,0 +1,4 @@
1
+ # 0.2.0
2
+
3
+ * Created upload_file_from_path to upload a file from a path
4
+ * And *changed* upload_file passing a file
@@ -49,11 +49,11 @@ module SharefileConnect
49
49
  JSON.parse(r.body)['Id'] if r.kind_of?(Net::HTTPOK)
50
50
  end
51
51
 
52
- def upload_file folder_id, file_path
52
+ def upload_file_from_path(folder_id, file_path)
53
53
  path = "/Items(#{folder_id})/Upload"
54
- response = HTTParty.get(full(path), headers: authorization_header)
54
+ response = get(path)
55
55
  upload_config = JSON.parse response.body
56
- multipart_form_post upload_config['ChunkUri'], file_path
56
+ multipart_form_post upload_config['ChunkUri'], File.read(file_path), File.basename(file_path)
57
57
  # HTTMultiParty.post(upload_config["ChunkUri"], body: { file1: File.new(file_path) } )
58
58
  # File.open(file_path) do |transfile|
59
59
  # # HTTMultiParty.post(upload_config["ChunkUri"], query: { file1: File.read(transfile) })
@@ -62,6 +62,13 @@ module SharefileConnect
62
62
  # end
63
63
  end
64
64
 
65
+ def upload_file(folder_id, file, file_name)
66
+ path = "/Items(#{folder_id})/Upload"
67
+ response = get(path)
68
+ upload_config = JSON.parse response.body
69
+ multipart_form_post upload_config['ChunkUri'], file, file_name
70
+ end
71
+
65
72
  def zones
66
73
  get("/Zones")
67
74
  end
@@ -72,9 +79,9 @@ module SharefileConnect
72
79
 
73
80
  private
74
81
 
75
- def multipart_form_post url, file_path
82
+ def multipart_form_post(url, file, file_name)
76
83
  newline = "\r\n"
77
- filename = File.basename(file_path)
84
+ filename = file_name
78
85
  boundary = "----------#{Time.now.nsec}"
79
86
 
80
87
  uri = URI.parse(url)
@@ -84,7 +91,7 @@ module SharefileConnect
84
91
  post_body << "Content-Disposition: form-data; name=\"File1\"; filename=\"#{filename}\"#{newline}"
85
92
  post_body << "Content-Type: application/octet-stream#{newline}"
86
93
  post_body << "#{newline}"
87
- post_body << File.read(file_path)
94
+ post_body << file
88
95
  post_body << "#{newline}--#{boundary}--#{newline}"
89
96
 
90
97
  request = Net::HTTP::Post.new(uri.request_uri)
@@ -1,3 +1,3 @@
1
1
  module SharefileConnect
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sharefile_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tubedude
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -97,6 +97,7 @@ files:
97
97
  - ".idea/workspace.xml"
98
98
  - ".rspec"
99
99
  - ".travis.yml"
100
+ - CHANGELOG.md
100
101
  - Gemfile
101
102
  - LICENSE.txt
102
103
  - README.md
@@ -129,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
130
  version: '0'
130
131
  requirements: []
131
132
  rubyforge_project:
132
- rubygems_version: 2.4.8
133
+ rubygems_version: 2.4.5.1
133
134
  signing_key:
134
135
  specification_version: 4
135
136
  summary: Another Sharefile Ruby Wrapper