Vapor Documentation Beta

Structure File

public struct File: Codable, Equatable

Represents a single file.

%3 File File Equatable Equatable File->Equatable Codable Codable File->Codable MultipartPartConvertible MultipartPartConvertible File->MultipartPartConvertible

Conforms To

MultipartPartConvertible
Codable
Equatable

Initializers

init?(multipart:​)

public init?(multipart: MultipartPart)

init(from:​)

public init(from decoder: Decoder) throws

Decodable conformance.

init(data:​filename:​)

public init(data: String, filename: String)

Creates a new File.

let file = File(data: "hello", filename: "foo.txt")

Parameters

data String

The file's contents.

filename String

The name of the file, not including path.

init(data:​filename:​)

public init(data: ByteBuffer, filename: String)

Creates a new File.

let file = File(data: "hello", filename: "foo.txt")

Parameters

data Byte​Buffer

The file's contents.

filename String

The name of the file, not including path.

Properties

multipart

var multipart: MultipartPart?

filename

var filename: String

Name of the file, including extension.

data

var data: ByteBuffer

The file's data.

content​Type

var contentType: HTTPMediaType?

Associated MediaType for this file's extension, if it has one.

`extension`

var `extension`: String?

The file extension, if it has one.

Methods

encode(to:​)

public func encode(to encoder: Encoder) throws

Encodable conformance.