Class: Keiyaku::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/keiyaku/runtime.rb,
sig/keiyaku.rbs

Overview

One file in a multipart/form-data body.

Keiyaku::Upload.new(File.open("kaya.png"))
Keiyaku::Upload.new(bytes, filename: "kaya.png", content_type: "image/png")

An IO passed on its own is wrapped in one of these, so the common case needs no ceremony. The content type is not guessed from the extension — a wrong one is worse than the honest default.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, filename: nil, content_type: nil) ⇒ Upload

Returns a new instance of Upload.

Parameters:

  • io (Object)
  • filename: (String, nil) (defaults to: nil)
  • content_type: (String, nil) (defaults to: nil)


129
# File 'sig/keiyaku.rbs', line 129

def initialize: (untyped io, ?filename: String?, ?content_type: String?) -> void

Instance Attribute Details

#content_typeString (readonly)

Returns the value of attribute content_type.

Returns:

  • (String)


127
128
129
# File 'sig/keiyaku.rbs', line 127

def content_type
  @content_type
end

#filenameString (readonly)

Returns the value of attribute filename.

Returns:

  • (String)


126
127
128
# File 'sig/keiyaku.rbs', line 126

def filename
  @filename
end

#ioObject (readonly)

Returns the value of attribute io.

Returns:

  • (Object)


125
126
127
# File 'sig/keiyaku.rbs', line 125

def io
  @io
end

Instance Method Details

#readString

Returns:

  • (String)


130
# File 'sig/keiyaku.rbs', line 130

def read: () -> String