Couchbase Lite
Objective-C API for iOS and Mac OS
Instance Methods | Properties | List of all members
CBLBlob Class Reference

Detailed Description

A CBLBlob appears as a property of a CBLDocument; it 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.

Inheritance diagram for CBLBlob:

Instance Methods

(nullable instancetype) - initWithContentType:data:error:
 Initializes a CBLBlob with the given in-memory data. More...
 
(nullable instancetype) - initWithContentType:contentStream:error:
 Initializes a CBLBlob with the given stream of data. More...
 
(nullable instancetype) - initWithContentType:fileURL:error:
 Initializes a CBLBlob with the contents of a file. More...
 
(instancetype) - NS_UNAVAILABLE
 

Properties

NSData * content
 Gets the contents of a CBLBlob as a block of memory. More...
 
NSInputStream * contentStream
 A stream of the content of a CBLBlob. More...
 
NSString * contentType
 The type of content this CBLBlob represents; by convention this is a MIME type. More...
 
uint64_t length
 The binary length of this CBLBlob. More...
 
NSString * digest
 The cryptographic digest of this CBLBlob's contents, which uniquely identifies it. More...
 
NSDictionary * properties
 The metadata associated with this CBLBlob. More...
 

Method Documentation

- (nullable instancetype) initWithContentType: (NSString *)  contentType
data: (NSData *)  data
error: (NSError **)  error 

Initializes a CBLBlob with the given in-memory data.

The blob can then be added as a property of a CBLDocument.

Parameters
contentTypeThe type of content this CBLBlob will represent.
dataThe data that this CBLBlob will contain.
errorOn return, the error if any.
- (nullable instancetype) initWithContentType: (NSString *)  contentType
contentStream: (NSInputStream *)  stream
error: (NSError **)  error 

Initializes a CBLBlob with the given stream of data.

The blob can then be added as a property of a CBLDocument.

Parameters
contentTypeThe type of content this CBLBlob will represent.
streamThe stream of data that this CBLBlob will consume.
errorOn return, the error if any.
- (nullable instancetype) initWithContentType: (NSString *)  contentType
fileURL: (NSURL *)  fileURL
error: (NSError **)  error 

Initializes a CBLBlob with the contents of a file.

The blob can then be added as a property of a CBLDocument.

Parameters
contentTypeThe type of content this CBLBlob will represent.
fileURLA URL to a file containing the data that this CBLBlob will represent.
errorOn return, the error if any.
- (instancetype) NS_UNAVAILABLE

Property Documentation

- (NSData*) content
readnonatomicassign

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.

- (NSInputStream*) contentStream
readnonatomicassign

A stream of the content of a CBLBlob.

The caller is responsible for opening the stream, and closing it when finished.

- (NSString*) contentType
readnonatomicassign

The type of content this CBLBlob represents; by convention this is a MIME type.

- (uint64_t) length
readnonatomicassign

The binary length of this CBLBlob.

- (NSString*) digest
readnonatomicassign

The cryptographic digest of this CBLBlob's contents, which uniquely identifies it.

- (NSDictionary*) properties
readnonatomicassign

The metadata associated with this CBLBlob.


The documentation for this class was generated from the following file: