Docs
Launch GraphOS Studio
You're viewing documentation for a previous version of this software. Switch to the latest stable version.


STRUCT

GraphQLFile

public struct GraphQLFile

A file which can be uploaded to a

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

octetStreamMimeType

public static let octetStreamMimeType = "application/octet-stream"

A convenience constant for declaring your mimetype is octet-stream.

Methods

init(fieldName:originalName:mimeType:data:)

public init(fieldName: String,
originalName: String,
mimeType: String = GraphQLFile.octetStreamMimeType,
data: Data)

Convenience initializer for raw data

  • Parameters:
    • Name: 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

NameDescription
fieldNameThe name of the field this file is being sent for
originalNameThe original name of the file
mimeTypeThe mime type of the file to send to the server. Defaults to GraphQLFile.octetStreamMimeType.
dataThe 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

NameDescription
fieldNameThe name of the field this file is being sent for
originalNameThe original name of the file
mimeTypeThe mime type of the file to send to the server. Defaults to GraphQLFile.octetStreamMimeType.
fileURLThe 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.
Next
Introduction
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company