Class Net::HTTP::FileForPost
In: multipart.rb
Parent: Object

When sending files via POST (rfc1867), the HTTP message has a special content-type: multipart/form-data. Its body includes zero or more key/value parameters like in other POST messages, plus one or more file upload parameters. File upload parameters are special:

  • A single parameter may carry more than one file. This technique is called multipart/mixed.
  • Each file (not parameter!) can include extra metadata: its filename and mimetype.

This class models the file arguments used in multipart/form-data. See Net::HTTP::Post#set_multipart_data for examples.

Methods

maybeclose   new   read  

Attributes

filename  [RW] 
input  [R] 
mimetype  [RW] 
shouldclose  [RW] 

Public Class methods

Arguments:

filepath_or_io:The file to upload; either the pathname to open, or an IO object. If it‘s a pathname, it will be opened now and closed automatically later.
mimetype:The content-type. Per RFC defaults to ‘application/octet-stream’, but I recommend setting it explicitly.
filename:The file name to send to the remote server. If not supplied, will guess one based on the file‘s path. You can set it later with filename=.

Public Instance methods

[Validate]