CBLBlob
@interface CBLBlob : NSObject
A CBLBlob 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 CBLBlob’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 CBLBlob with the given in-memory data.
Declaration
Objective-C
- (nonnull instancetype)initWithContentType:(nonnull NSString *)contentType data:(nonnull NSData *)data;
Parameters
contentType
The type of content this CBLBlob will represent.
data
The data that this CBLBlob will contain.
Return Value
The CBLBlob object.
-
Initializes a CBLBlob with the given stream of data.
Declaration
Objective-C
- (nonnull instancetype)initWithContentType:(nonnull NSString *)contentType contentStream:(nonnull NSInputStream *)stream;
Parameters
contentType
The type of content this CBLBlob will represent.
stream
The stream of data that this CBLBlob will consume.
Return Value
The CBLBlob object.
-
Initializes a CBLBlob with the contents of a file.
Declaration
Objective-C
- (nullable instancetype)initWithContentType:(nonnull NSString *)contentType fileURL:(nonnull NSURL *)fileURL error: (NSError *_Nullable *_Nullable)error;
Parameters
contentType
The type of content this CBLBlob will represent.
fileURL
A URL to a file containing the data that this CBLBlob will represent.
error
On return, the error if any.
Return Value
The CBLBlob object.
-
The -init method is not available.
Declaration
Objective-C
- (nonnull instancetype)init;
-
Gets the contents of a CBLBlob as a block of memory. Not recommended for very large blobs, as it may be slow and use up lots of RAM.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSData *content;
-
A stream of the content of a CBLBlob. The caller is responsible for opening the stream, and closing it when finished.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSInputStream *contentStream;
-
The type of content this CBLBlob represents; by convention this is a MIME type.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *contentType;
-
The binary length of this CBLBlob.
Declaration
Objective-C
@property (nonatomic, readonly) uint64_t length;
-
The cryptographic digest of this CBLBlob’s contents, which uniquely identifies it.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *digest;
-
The metadata associated with this CBLBlob
Declaration
Objective-C
@property (nonatomic, readonly) NSDictionary<NSString *, id> *_Nonnull properties;