Couchbase Lite
Objective-C API for iOS and Mac OS
CBLAttachment Class Reference

Detailed Description

A binary attachment to a document revision.

Existing attachments can be gotten from -[CBLRevision attachmentNamed:]. New attachments can be created by calling the -setAttachment:... methods of CBLNewRevision or CBLModel.

Inheritance diagram for CBLAttachment:

Instance Methods

(nullable NSInputStream *) - openContentStream
 Returns a stream from which you can read the data of the attachment. More...
 
(BOOL) - purge
 Deletes the attachment's contents from local storage. More...
 
(instancetype) - NS_UNAVAILABLE
 

Properties

CBLRevisionrevision
 The owning document revision. More...
 
CBLDocumentdocument
 The owning document. More...
 
NSString * name
 The filename. More...
 
NSString * contentType
 The MIME type of the contents. More...
 
UInt64 length
 The length in bytes of the contents. More...
 
UInt64 encodedLength
 The length in bytes of the encoded form of the attachment. More...
 
CBLJSONDict * metadata
 The Couchbase Lite metadata about the attachment, that lives in the document. More...
 
BOOL contentAvailable
 Is the content locally available? This may be NO if the attachment's document was pulled from a remote database by a CBLReplication whose downloadAttachments property was NO. More...
 
NSData * content
 The data of the attachment. More...
 
NSURL * contentURL
 The (file:) URL of the file containing the contents. More...
 

Method Documentation

◆ openContentStream()

- (nullable NSInputStream*) openContentStream

Returns a stream from which you can read the data of the attachment.

Remember to close it when you're done.

◆ purge()

- (BOOL) purge

Deletes the attachment's contents from local storage.

If the attachment is still available on a remote server, it can be restored by calling -[CBLReplication downloadAttachment:onProgress:].

◆ NS_UNAVAILABLE()

- (instancetype) NS_UNAVAILABLE

Property Documentation

◆ revision

- (CBLRevision*) revision
readatomicretain

The owning document revision.

◆ document

- (CBLDocument*) document
readatomicassign

The owning document.

◆ name

- (NSString*) name
readatomiccopy

The filename.

◆ contentType

- (NSString*) contentType
readatomicassign

The MIME type of the contents.

◆ length

- (UInt64) length
readatomicassign

The length in bytes of the contents.

◆ encodedLength

- (UInt64) encodedLength
readatomicassign

The length in bytes of the encoded form of the attachment.

This may be smaller than the length if the attachment is stored in compressed form.

◆ metadata

- (CBLJSONDict*) metadata
readatomicassign

The Couchbase Lite metadata about the attachment, that lives in the document.

◆ contentAvailable

- (BOOL) contentAvailable
readatomicassign

Is the content locally available? This may be NO if the attachment's document was pulled from a remote database by a CBLReplication whose downloadAttachments property was NO.

If so, the content accessors will return nil. The attachment can be downloaded by calling the replication's -downloadAttachment:onProgress: method.

◆ content

- (NSData*) content
readatomicassign

The data of the attachment.

◆ contentURL

- (NSURL*) contentURL
readatomicassign

The (file:) URL of the file containing the contents.

This property is somewhat deprecated and is made available only for use with platform APIs that require file paths/URLs, e.g. some media playback APIs. Whenever possible, use the content property or the openContentStream method instead. The file must be treated as read-only! DO NOT MODIFY OR DELETE IT. If the database is encrypted, attachment files are also encrypted and not directly readable, so this property will return nil.


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