Class UploadIO
In: lib/composite_io.rb
Parent: Object

Convenience methods for dealing with files and IO that are to be uploaded.

Methods

Attributes

content_type  [R]  Create an upload IO suitable for including in the params hash of a Net::HTTP::Post::Multipart.

Can take two forms. The first accepts a filename and content type, and opens the file for reading (to be closed by finalizer).

The second accepts an already-open IO, but also requires a third argument, the filename from which it was opened (particularly useful/recommended if uploading directly from a form in a framework, which often save the file to an arbitrarily named RackMultipart file in /tmp).

Usage:

    UploadIO.new("file.txt", "text/plain")
    UploadIO.new(file_io, "text/plain", "file.txt")
io  [R]  Create an upload IO suitable for including in the params hash of a Net::HTTP::Post::Multipart.

Can take two forms. The first accepts a filename and content type, and opens the file for reading (to be closed by finalizer).

The second accepts an already-open IO, but also requires a third argument, the filename from which it was opened (particularly useful/recommended if uploading directly from a form in a framework, which often save the file to an arbitrarily named RackMultipart file in /tmp).

Usage:

    UploadIO.new("file.txt", "text/plain")
    UploadIO.new(file_io, "text/plain", "file.txt")
local_path  [R]  Create an upload IO suitable for including in the params hash of a Net::HTTP::Post::Multipart.

Can take two forms. The first accepts a filename and content type, and opens the file for reading (to be closed by finalizer).

The second accepts an already-open IO, but also requires a third argument, the filename from which it was opened (particularly useful/recommended if uploading directly from a form in a framework, which often save the file to an arbitrarily named RackMultipart file in /tmp).

Usage:

    UploadIO.new("file.txt", "text/plain")
    UploadIO.new(file_io, "text/plain", "file.txt")
opts  [R]  Create an upload IO suitable for including in the params hash of a Net::HTTP::Post::Multipart.

Can take two forms. The first accepts a filename and content type, and opens the file for reading (to be closed by finalizer).

The second accepts an already-open IO, but also requires a third argument, the filename from which it was opened (particularly useful/recommended if uploading directly from a form in a framework, which often save the file to an arbitrarily named RackMultipart file in /tmp).

Usage:

    UploadIO.new("file.txt", "text/plain")
    UploadIO.new(file_io, "text/plain", "file.txt")
original_filename  [R]  Create an upload IO suitable for including in the params hash of a Net::HTTP::Post::Multipart.

Can take two forms. The first accepts a filename and content type, and opens the file for reading (to be closed by finalizer).

The second accepts an already-open IO, but also requires a third argument, the filename from which it was opened (particularly useful/recommended if uploading directly from a form in a framework, which often save the file to an arbitrarily named RackMultipart file in /tmp).

Usage:

    UploadIO.new("file.txt", "text/plain")
    UploadIO.new(file_io, "text/plain", "file.txt")

Public Class methods

Public Instance methods

[Validate]