httpclient-uploadio 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in httpclient-uploadio.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 jugyo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ httpclient-uploadio
2
+ ====
3
+
4
+ You can upload an IO to web server through httpclient-uploadio.
5
+
6
+ Install
7
+ ----
8
+
9
+ gem install httpclient-uploadio
10
+
11
+ Example
12
+ ----
13
+
14
+ require 'httpclient/uploadio'
15
+ require 'stringio'
16
+
17
+ io = HTTPClient::UploadIO.new(StringIO.new("foo"), "foo.txt") # create UploadIO
18
+ client = HTTPClient.new
19
+ response = client.post('http://localhost:4567/', :file => io) # post
20
+ puts "response: #{response.body}"
21
+
22
+ Copyright
23
+ ----
24
+
25
+ Copyright (c) 2011 jugyo. See LICENSE.txt for further details.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ # Server example:
2
+ #
3
+ # require 'sinatra'
4
+ # post '/' do
5
+ # params[:file][:tempfile].read
6
+ # end
7
+ #
8
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
9
+ require 'httpclient/uploadio'
10
+ require 'stringio'
11
+
12
+ stringio = StringIO.new("foo")
13
+ io = HTTPClient::UploadIO.new(stringio, "foo.txt")
14
+ client = HTTPClient.new
15
+ response = client.post('http://localhost:4567/', :file => io)
16
+ puts "response: #{response.body}"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |gem|
3
+ gem.authors = ["jugyo"]
4
+ gem.email = ["jugyo.org@gmail.com"]
5
+ gem.description = %q{You can upload an IO to a web server through httpclient-uploadio.}
6
+ gem.summary = %q{Wrapper for IO to upload to web server}
7
+ gem.homepage = "https://github.com/jugyo/httpclient-uploadio"
8
+
9
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
10
+ gem.files = `git ls-files`.split("\n")
11
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
12
+ gem.name = "httpclient-uploadio"
13
+ gem.require_paths = ["lib"]
14
+ gem.version = '1.0.0'
15
+
16
+ gem.add_dependency 'httpclient', '~> 2.2'
17
+ end
@@ -0,0 +1,7 @@
1
+ require "httpclient-uploadio/version"
2
+
3
+ module Httpclient
4
+ module Uploadio
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ require 'forwardable'
2
+ require 'httpclient'
3
+
4
+ class HTTPClient
5
+ class UploadIO
6
+ extend Forwardable
7
+ def_delegators :@io, :read, :pos, :pos=, :size
8
+
9
+ attr_reader :io, :path
10
+
11
+ def initialize(io, path = '')
12
+ @io = io
13
+ @path = path
14
+ end
15
+
16
+ def content_type
17
+ HTTP::Message.mime_type(path)
18
+ end
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: httpclient-uploadio
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - jugyo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-13 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httpclient
16
+ requirement: &2153480020 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2153480020
25
+ description: You can upload an IO to a web server through httpclient-uploadio.
26
+ email:
27
+ - jugyo.org@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - Gemfile
33
+ - LICENSE.txt
34
+ - README.md
35
+ - Rakefile
36
+ - examples/upload.rb
37
+ - httpclient-uploadio.gemspec
38
+ - lib/httpclient-uploadio.rb
39
+ - lib/httpclient/uploadio.rb
40
+ homepage: https://github.com/jugyo/httpclient-uploadio
41
+ licenses: []
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.11
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Wrapper for IO to upload to web server
64
+ test_files: []