| 1 |
= multipart-post |
|---|
| 2 |
|
|---|
| 3 |
* http://svn.caldersphere.net/svn/main/multipart-post |
|---|
| 4 |
|
|---|
| 5 |
== DESCRIPTION: |
|---|
| 6 |
|
|---|
| 7 |
Adds a multipart form post capability to Net::HTTP. |
|---|
| 8 |
|
|---|
| 9 |
== FEATURES/PROBLEMS: |
|---|
| 10 |
|
|---|
| 11 |
I wrote this a while ago and never ended up using it. It appears to work, |
|---|
| 12 |
but I don't know for sure. If you find any bugs or improvements, please |
|---|
| 13 |
let me know! |
|---|
| 14 |
|
|---|
| 15 |
== SYNOPSIS: |
|---|
| 16 |
|
|---|
| 17 |
require 'net/http/post/multipart' |
|---|
| 18 |
|
|---|
| 19 |
url = URI.parse('http://www.example.com/upload') |
|---|
| 20 |
req = File.open("./image.jpg") do |jpg| |
|---|
| 21 |
Net::HTTP::Post::Multipart.new(url.path, { |
|---|
| 22 |
"file" => UploadIO.convert!(jpg, "image/jpeg", "image.jpg", "./image.jpg")}) |
|---|
| 23 |
end |
|---|
| 24 |
res = Net::HTTP.start(url.host, url.port) do |http| |
|---|
| 25 |
http.request(req) |
|---|
| 26 |
end |
|---|
| 27 |
|
|---|
| 28 |
== REQUIREMENTS: |
|---|
| 29 |
|
|---|
| 30 |
None |
|---|
| 31 |
|
|---|
| 32 |
== INSTALL: |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
== LICENSE: |
|---|
| 36 |
|
|---|
| 37 |
(The MIT License) |
|---|
| 38 |
|
|---|
| 39 |
Copyright (c) 2007-2008 Nick Sieger <nick@nicksieger.com> |
|---|
| 40 |
|
|---|
| 41 |
Permission is hereby granted, free of charge, to any person obtaining |
|---|
| 42 |
a copy of this software and associated documentation files (the |
|---|
| 43 |
'Software'), to deal in the Software without restriction, including |
|---|
| 44 |
without limitation the rights to use, copy, modify, merge, publish, |
|---|
| 45 |
distribute, sublicense, and/or sell copies of the Software, and to |
|---|
| 46 |
permit persons to whom the Software is furnished to do so, subject to |
|---|
| 47 |
the following conditions: |
|---|
| 48 |
|
|---|
| 49 |
The above copyright notice and this permission notice shall be |
|---|
| 50 |
included in all copies or substantial portions of the Software. |
|---|
| 51 |
|
|---|
| 52 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|---|
| 53 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|---|
| 54 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|---|
| 55 |
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|---|
| 56 |
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|---|
| 57 |
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|---|
| 58 |
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|---|