Module Wrest::Multipart

  1. lib/wrest/multipart.rb

To enable Multipart support, use

require 'wrest/multipart'

Multipart support is currently only available on Net::Http and not when using libcurl. It depends on the multipart-post gem being available. To install multipart-post

(sudo) gem install multipart-post

The methods in this module are mixed into Wrest::Uri.

Methods

public instance

  1. post_multipart
  2. put_multipart

Public instance methods

post_multipart (parameters = {}, headers = {}, &block)

Makes a multipart/form-data encoded POST request to this URI. This is a convenience API that mimics a multipart form being posted; some allegedly RESTful APIs like FCBK require this for file uploads.

File.open('/path/to/image.jpg') do |file|
  'http://localhost:3000/uploads'.to_uri.post_multipart('file' => UploadIO.new(file, "image/jpg", '/path/to/image.jpg'))
end
[show source]
    # File lib/wrest/multipart.rb, line 37
37:     def post_multipart(parameters = {}, headers = {}, &block)
38:       Http::PostMultipart.new(self, parameters, headers, block ? @options.merge(:callback_block => block) : @options).invoke
39:     end
put_multipart (parameters = {}, headers = {}, &block)

Makes a multipart/form-data encoded PUT request to this URI. This is a convenience API that mimics a multipart form being put. I sincerely hope you never need to use this.

[show source]
    # File lib/wrest/multipart.rb, line 43
43:     def put_multipart(parameters = {}, headers = {}, &block)
44:       Http::PutMultipart.new(self, parameters, headers, block ? @options.merge(:callback_block => block) : @options).invoke
45:     end