6.1 Lock/Unlock File
6.1.1 Lock File
The lockFile:success:failure
method of BayunCore
class locks a file with default encryption-policy
and key-generation-policy
dictated by server settings.
Method parameters :
filePath : File path to be locked.
dataType :
NSURL
success : Success block to be executed after file is successfully locked.
failure : Failure block to be executed if file locking fails, returns
BayunError
.
The file at the given file path is overwritten with the locked file. If file locking fails original file is not changed.
NSURL *fileURL = [NSURL fileURLWithPath:@"your file path"];
[[BayunCore sharedInstance] lockFile:fileURL success:^{
NSLog(@"File locked successfully.");
} failure:^(BayunError errorCode) {
NSLog(@"Error locking file.");
}];
6.1.2 Lock File with Encryption Policy, Key Generation Policy
The lockFile:encryptionPolicy:keyGenerationPolicy:groupId:success:failure
method with encryption-policy as an optional parameter locks file with the encryption key dictated by the policy. The method takes the following parameters :
fileURL : File path to be locked.
encryptionPolicy : BayunEncryptionPolicy determines the key for locking.
keyGenerationPolicy : BayunKeyGenerationPolicy determines the policy to generate the data encryption key.
groupId : GroupId is required if encryptionPolicy is
BayunEncryptionPolicyGroup
.success : Success block to be executed after file is successfully locked.
failure : Failure block to be executed if locking fails, returns
BayunError
.
NSURL *fileURL = [NSURL fileURLWithPath:@"your file path"];
[[BayunCore sharedInstance] lockFile:fileURL
encryptionPolicy:encryptionPolicy
keyGenerationPolicy:keyGenerationPolicy
groupId:groupId
success:^{
NSLog(@"File locked successfully.");
} failure:^(BayunError errorCode) {
NSLog(@"Error locking file.");
}];
6.1.3 Unlock File
The unlockFile
method of BayunCore
class unlocks a locked file. The method takes the following parameters :
filePath : File path to be unlocked.
dataType :
NSURL
success : Success block to be executed after file is successfully unlocked.
failure : Failure block to be executed if file unlocking fails, returns
BayunError
.
The file at the given file path is overwritten with the unlocked file.
NSURL *fileURL = [NSURL fileURLWithPath:@"your file path"];
[[BayunCore sharedInstance] unlockFile:fileURL success:^{
NSLog(@"File unlocked successfully.");
} failure:^(BayunError errorCode) {
NSLog(@"Error unlocking file.");
}];
Last updated
Was this helpful?