GraphQLFile
STRUCT
GraphQLFile
1public struct GraphQLFile: HashableA file which can be uploaded to a GraphQL server
Properties
fieldName
1public let fieldName: StringoriginalName
1public let originalName: StringmimeType
1public let mimeType: Stringdata
1public let data: Data?fileURL
1public let fileURL: URL?contentLength
1public let contentLength: UInt64octetStreamMimeType
1public static let octetStreamMimeType = "application/octet-stream"A convenience constant for declaring your mimetype is octet-stream.
Methods
init(fieldName:originalName:mimeType:data:)
1public init(fieldName: String,
2 originalName: String,
3 mimeType: String = GraphQLFile.octetStreamMimeType,
4 data: Data)Convenience initializer for raw data
Parameters:
fieldName: The name of the field this file is being sent for
originalName: The original name of the file
mimeType: The mime type of the file to send to the server. Defaults to
GraphQLFile.octetStreamMimeType.data: The raw data to send for the file.
Parameters
| Name | Description |
|---|---|
| fieldName | The name of the field this file is being sent for |
| originalName | The original name of the file |
| mimeType | The mime type of the file to send to the server. Defaults to GraphQLFile.octetStreamMimeType. |
| data | The raw data to send for the file. |
init(fieldName:originalName:mimeType:fileURL:)
1public init(fieldName: String,
2 originalName: String,
3 mimeType: String = GraphQLFile.octetStreamMimeType,
4 fileURL: URL) throwsThrowing convenience initializer for files in the filesystem
Parameters:
fieldName: The name of the field this file is being sent for
originalName: The original name of the file
mimeType: The mime type of the file to send to the server. Defaults to
GraphQLFile.octetStreamMimeType.fileURL: The URL of the file to upload.
Throws: If the file's size could not be determined
Parameters
| Name | Description |
|---|---|
| fieldName | The name of the field this file is being sent for |
| originalName | The original name of the file |
| mimeType | The mime type of the file to send to the server. Defaults to GraphQLFile.octetStreamMimeType. |
| fileURL | The URL of the file to upload. |
generateInputStream()
1public func generateInputStream() throws -> InputStreamUses either the data or the file URL to create an
InputStream that can be used to stream data into
a multipart-form.
Returns: The created
InputStream.Throws: If an input stream could not be created from either data or a file URL.