STRUCT
GraphQLFile
public struct GraphQLFile
A file which can be uploaded to a GraphQL server
Properties
fieldName
public let fieldName: String
originalName
public let originalName: String
mimeType
public let mimeType: String
data
public let data: Data?
fileURL
public let fileURL: URL?
contentLength
public let contentLength: UInt64
Methods
init(fieldName:originalName:mimeType:data:)
public init(fieldName: String,
originalName: String,
mimeType: String = GraphQLFile.octetStreamMimeType,
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:)
public init(fieldName: String,
originalName: String,
mimeType: String = GraphQLFile.octetStreamMimeType,
fileURL: URL) throws
Throwing 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()
public func generateInputStream() throws -> InputStream
Uses 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.