Blob
public final class Blob: Equatable, Hashable
Blob contains arbitrary binary data, tagged with a MIME type.
Blobs can be arbitrarily large, and their data is loaded only on demand (when the content
or contentStream
properties are accessed), not when the document is loaded.
The document’s raw JSON form only contains the Blob’s metadata (type, length and a digest of
the data) in a small object. The data itself is stored externally to the document, keyed by
the digest.
-
Initializes a Blob with the given in-memory data.
Declaration
Swift
public convenience init(contentType: String, data: Data)
Parameters
contentType
The type of content this Blob will represent.
data
The data that this Blob will contain.
-
Initializes a Blob with the given stream of data.
Declaration
Swift
public convenience init(contentType: String, contentStream: InputStream)
Parameters
contentType
The type of content this Blob will represent.
contentStream
The stream of data that this Blob will consume.
-
Initializes a Blob with the contents of a file.
Throws
An error on a failure.Declaration
Swift
public convenience init(contentType: String, fileURL: URL) throws
Parameters
contentType
The type of content this Blob will represent.
fileURL
A URL to a file containing the data that this Blob will represent.
-
Gets the contents of a Blob as a block of memory. Not recommended for very large blobs, as it may be slow and use up lots of RAM.
Declaration
Swift
public var content: Data?
-
A stream of the content of a Blob. The caller is responsible for opening the stream, and closing it when finished.
Declaration
Swift
public var contentStream: InputStream?
-
The type of content this Blob represents; by convention this is a MIME type.
Declaration
Swift
public var contentType: String?
-
The binary length of this Blob.
Declaration
Swift
public var length: UInt64
-
The cryptographic digest of this Blob’s contents, which uniquely identifies it.
Declaration
Swift
public var digest: String?
-
The metadata associated with this Blob
Declaration
Swift
public var properties: [String: Any]
-
Equal to operator for comparing two Blob objects.
Declaration
Swift
public static func == (blob1: Blob, blob2: Blob) -> Bool