-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replication encoding/encryption API now supports attachments.
During a pull, the _attachments objects for large attachments will have a temporary "file" property that points to the local file path where the attachment data can be found. The transformation block can read this file, but must not modify it.
- Loading branch information
Showing
12 changed files
with
218 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// CBLReplication+Transformation.h | ||
// CouchbaseLite | ||
// | ||
// Created by Jens Alfke on 3/14/14. | ||
// | ||
// | ||
|
||
#import <CouchbaseLite/CouchbaseLite.h> | ||
|
||
|
||
/** A callback block for transforming revision bodies during replication. | ||
See CBLReplication.propertiesTransformationBlock's documentation for details. */ | ||
typedef NSDictionary *(^CBLPropertiesTransformationBlock)(NSDictionary* doc); | ||
|
||
|
||
@interface CBLReplication (Transformation) | ||
|
||
/** Optional callback for transforming document bodies during replication; can be used to encrypt documents stored on the remote server, for example. | ||
In a push replication, the block is called with document properties from the local database, and the transformed properties are what will be uploaded to the server. | ||
In a pull replication, the block is called with document properties downloaded from the server, and the transformed properties are what will be stored in the local database. | ||
The block takes an NSDictionary containing the document's properties (including the "_id" and "_rev" metadata), and returns a dictionary of transformed properties. It may return the input dictionary if it has no changes to make. | ||
The transformation MUST preserve the values of any keys whose names begin with an underscore ("_")! | ||
The block will be called on the background replicator thread, NOT on the CBLReplication's thread, so it shouldn't directly access any Couchbase Lite objects. */ | ||
@property (strong) CBLPropertiesTransformationBlock propertiesTransformationBlock; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// CBLReplication+Transformation.m | ||
// CouchbaseLite | ||
// | ||
// Created by Jens Alfke on 3/14/14. | ||
// | ||
// | ||
|
||
#import "CBLReplication+Transformation.h" | ||
#import "CouchbaseLitePrivate.h" | ||
|
||
|
||
@implementation CBLReplication (Transformation) | ||
|
||
- (CBLPropertiesTransformationBlock) propertiesTransformationBlock { | ||
return _propertiesTransformationBlock; | ||
} | ||
|
||
- (void) setPropertiesTransformationBlock:(CBLPropertiesTransformationBlock)block { | ||
_propertiesTransformationBlock = block; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.