Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: ebe96434dc
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (47 sloc) 2.65 KB
// TDDatabase+Attachments.h
// TouchDB
// Created by Jens Alfke on 1/18/12.
// Copyright (c) 2012 Couchbase, Inc. All rights reserved.
#import "TDDatabase.h"
@class TDBlobStoreWriter;
/** Types of encoding/compression of stored attachments. */
typedef enum {
} TDAttachmentEncoding;
@interface TDDatabase (Attachments)
/** Creates a TDBlobStoreWriter object that can be used to stream an attachment to the store. */
- (TDBlobStoreWriter*) attachmentWriter;
/** Given a newly-added revision, adds the necessary attachment rows to the database and stores inline attachments into the blob store. */
- (TDStatus) processAttachmentsForRevision: (TDRevision*)rev
withParentSequence: (SequenceNumber)parentSequence;
/** Constructs an "_attachments" dictionary for a revision, to be inserted in its JSON body. */
- (NSDictionary*) getAttachmentDictForSequence: (SequenceNumber)sequence
options: (TDContentOptions)options;
/** Modifies a TDRevision's body by changing all attachments with revpos < minRevPos into stubs. */
+ (void) stubOutAttachmentsIn: (TDRevision*)rev beforeRevPos: (int)minRevPos;
/** Returns the content and metadata of an attachment.
If you pass NULL for the 'outEncoding' parameter, it signifies that you don't care about encodings and just want the 'real' data, so it'll be decoded for you. */
- (NSData*) getAttachmentForSequence: (SequenceNumber)sequence
named: (NSString*)filename
type: (NSString**)outType
encoding: (TDAttachmentEncoding*)outEncoding
status: (TDStatus*)outStatus;
/** Uses the "digest" field of the attachment dict to look up the attachment in the store and return an input stream to read its data. */
- (NSInputStream*) inputStreamForAttachmentDict: (NSDictionary*)attachmentDict
length: (UInt64*)outLength;
/** Deletes obsolete attachments from the database and blob store. */
- (TDStatus) garbageCollectAttachments;
/** Updates or deletes an attachment, creating a new document revision in the process.
Used by the PUT / DELETE methods called on attachment URLs. */
- (TDRevision*) updateAttachment: (NSString*)filename
body: (NSData*)body
type: (NSString*)contentType
encoding: (TDAttachmentEncoding)encoding
ofDocID: (NSString*)docID
revID: (NSString*)oldRevID
status: (TDStatus*)outStatus;
Jump to Line
Something went wrong with that request. Please try again.