Skip to content

Commit

Permalink
Updated docs and reformatted some code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Cobbe committed May 1, 2017
1 parent 766b685 commit be1e34e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 46 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,15 @@ Here's an example for listing a folder's contents. In the response handler, we r
```objective-c
NSData *fileData = [@"file data example" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];
[[[client.filesRoutes uploadData:@"/test/path/in/Dropbox/account/my_output.txt" inputData:fileData]
// For overriding on upload
DBFILESWriteMode *mode = [[DBFILESWriteMode alloc] initWithOverwrite];
[[[client.filesRoutes uploadData:@"/test/path/in/Dropbox/account/my_output.txt"
mode:mode
autorename:@(YES)
clientModified:nil
mute:@(NO)
inputData:fileData]
setResponseBlock:^(DBFILESFileMetadata *result, DBFILESUploadError *routeError, DBRequestError *networkError) {
if (result) {
NSLog(@"%@\n", result);
Expand All @@ -567,7 +575,7 @@ NSData *fileData = [@"file data example" dataUsingEncoding:NSUTF8StringEncoding
}];
```

[-uploadData:inputData:](http://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/Classes/DBFILESUserAuthRoutes.html#/c:objc(cs)DBFILESUserAuthRoutes(im)uploadData:inputData:)
[-uploadData:mode:autorename:clientModified:mute:inputData:](http://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/Classes/DBFILESUserAuthRoutes.html#/c:objc(cs)DBFILESUserAuthRoutes(im)uploadData:mode:autorename:clientModified:mute:inputData:)

Here's an example of an advanced upload case for "batch" uploading a large number of files:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ - (BOOL)canPresentExternalApp:(NSURL * _Nonnull)url {

- (void)dismissAuthController {
if (_controller != nil) {
if (_controller.presentedViewController != nil && _controller.presentedViewController.isBeingDismissed == NO && [_controller.presentedViewController isKindOfClass:[DBMobileSafariViewController class]]) {
if (_controller.presentedViewController != nil && _controller.presentedViewController.isBeingDismissed == NO &&
[_controller.presentedViewController isKindOfClass:[DBMobileSafariViewController class]]) {
[_controller dismissViewControllerAnimated:YES completion:nil];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,29 @@ - (DBOpenWithInfo *)openWithInfoFromURL:(NSURL *)url {
NSArray<NSURLQueryItem *> *queryItems = urlComponents.queryItems;
if (queryItems) {
openWithInfo = [[DBOpenWithInfo alloc]
initWithUserId:[NSString
stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"uid" queryItems:queryItems]]
rev:[NSString
stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"rev" queryItems:queryItems]]
path:[NSString
stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"path" queryItems:queryItems]]
.lowercaseString
modifiedTime:[[self.class dateFormatter]
dateFromString:[NSString
stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"modifiedTime"
queryItems:queryItems]]]
readOnly:[[NSString stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"readOnly"
queryItems:queryItems]] boolValue]
verb:[NSString
stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"verb" queryItems:queryItems]]
sessionId:[NSString stringWithFormat:@"%@",
[[self class] getQueryItemValueFromName:@"sessionId" queryItems:queryItems]]
fileId:nil
fileData:nil
sourceApp:[NSString stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"sourceApp"
queryItems:queryItems]]];
initWithUserId:[NSString stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"uid"
queryItems:queryItems]]
rev:[NSString stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"rev"
queryItems:queryItems]]
path:[NSString stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"path"
queryItems:queryItems]]
.lowercaseString
modifiedTime:[[self.class dateFormatter]
dateFromString:[NSString
stringWithFormat:@"%@",
[[self class] getQueryItemValueFromName:@"modifiedTime"
queryItems:queryItems]]]
readOnly:[[NSString stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"readOnly"
queryItems:queryItems]]
boolValue]
verb:[NSString stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"verb"
queryItems:queryItems]]
sessionId:[NSString stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"sessionId"
queryItems:queryItems]]
fileId:nil
fileData:nil
sourceApp:[NSString stringWithFormat:@"%@", [[self class] getQueryItemValueFromName:@"sourceApp"
queryItems:queryItems]]];
NSAssert(openWithInfo, @"Error creating OpenWith info.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,10 @@ - (void)URLSession:(NSURLSession *)session
[sessionData.responseHandlerQueues removeObjectForKey:taskId];
[sessionData.progressHandlerQueues removeObjectForKey:taskId];
} else {
sessionData.completionData[taskId] =
[[DBCompletionData alloc] initWithCompletionData:nil
responseMetadata:downloadTask.response
responseError:fileMoveError
urlOutput:tmpOutputUrl];
sessionData.completionData[taskId] = [[DBCompletionData alloc] initWithCompletionData:nil
responseMetadata:downloadTask.response
responseError:fileMoveError
urlOutput:tmpOutputUrl];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ - (void)removeDownloadDataTask:(DBDownloadDataTaskImpl *)task {
}

- (BOOL)tasksInProgress {
@synchronized (self) {
@synchronized(self) {
return [_uploadTasks count] > 0 || [_downloadUrlTasks count] > 0 || [_downloadDataTasks count] > 0;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,26 +457,28 @@ + (void)convertV1TokenToV2:(NSMutableArray<NSArray<NSString *> *> *)v1TokensData

static NSOperationQueue *_v1TokenConversionOperationQueue = nil;
+ (NSOperationQueue *)v1TokenConversionOperationQueue {
static dispatch_once_t tokenConversionOnceToken;
dispatch_once(&tokenConversionOnceToken, ^{
_v1TokenConversionOperationQueue = [[NSOperationQueue alloc] init];
_v1TokenConversionOperationQueue.name = [NSString stringWithFormat:@"%@ %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)];
_v1TokenConversionOperationQueue.qualityOfService = NSQualityOfServiceUtility;
});

return _v1TokenConversionOperationQueue;
static dispatch_once_t tokenConversionOnceToken;
dispatch_once(&tokenConversionOnceToken, ^{
_v1TokenConversionOperationQueue = [[NSOperationQueue alloc] init];
_v1TokenConversionOperationQueue.name =
[NSString stringWithFormat:@"%@ %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)];
_v1TokenConversionOperationQueue.qualityOfService = NSQualityOfServiceUtility;
});

return _v1TokenConversionOperationQueue;
}

static NSOperationQueue *_rpcTaskOperationQueue = nil;
+ (NSOperationQueue *)rpcTaskOperationQueue {
static dispatch_once_t rpcTaskOnceToken;
dispatch_once(&rpcTaskOnceToken, ^{
_rpcTaskOperationQueue = [[NSOperationQueue alloc] init];
_rpcTaskOperationQueue.name = [NSString stringWithFormat:@"%@ %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)];
_rpcTaskOperationQueue.qualityOfService = NSQualityOfServiceUtility;
});

return _rpcTaskOperationQueue;
static dispatch_once_t rpcTaskOnceToken;
dispatch_once(&rpcTaskOnceToken, ^{
_rpcTaskOperationQueue = [[NSOperationQueue alloc] init];
_rpcTaskOperationQueue.name =
[NSString stringWithFormat:@"%@ %@", NSStringFromClass(self.class), NSStringFromSelector(_cmd)];
_rpcTaskOperationQueue.qualityOfService = NSQualityOfServiceUtility;
});

return _rpcTaskOperationQueue;
}

@end

0 comments on commit be1e34e

Please sign in to comment.