|
@@ -277,32 +277,25 @@
|
|
#pragma mark ===== downloadThumbnail / downloadPreview =====
|
|
#pragma mark ===== downloadThumbnail / downloadPreview =====
|
|
#pragma --------------------------------------------------------------------------------------------
|
|
#pragma --------------------------------------------------------------------------------------------
|
|
|
|
|
|
-- (void)downloadThumbnailWithDimOfThumbnail:(NSString *)dimOfThumbnail fileID:(NSString*)fileID fileNamePath:(NSString *)fileNamePath fileNameView:(NSString *)fileNameView completion:(void (^)(NSString *message, NSInteger errorCode))completion
|
|
|
|
|
|
+- (void)downloadThumbnailWithMetadata:(tableMetadata*)metadata serverUrl:(NSString *)serverUrl withWidth:(CGFloat)width andHeight:(CGFloat)height completion:(void (^)(NSString *message, NSInteger errorCode))completion
|
|
{
|
|
{
|
|
- OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
|
|
|
+ NSString *file = [NSString stringWithFormat:@"%@/%@.ico", [CCUtility getDirectoryProviderStorageFileID:metadata.fileID], metadata.fileNameView];
|
|
|
|
|
|
- NSInteger width = 0, height = 0;
|
|
|
|
-
|
|
|
|
- if ([dimOfThumbnail.lowercaseString isEqualToString:@"xs"]) { width = 32; height = 32;}
|
|
|
|
- else if ([dimOfThumbnail.lowercaseString isEqualToString:@"s"]) { width = 64; height = 64;}
|
|
|
|
- else if ([dimOfThumbnail.lowercaseString isEqualToString:@"m"]) { width = 128; height = 128;}
|
|
|
|
- else if ([dimOfThumbnail.lowercaseString isEqualToString:@"l"]) { width = 640; height = 640;}
|
|
|
|
- else if ([dimOfThumbnail.lowercaseString isEqualToString:@"xl"]) { width = 1024; height = 1024;}
|
|
|
|
-
|
|
|
|
- NSString *fileNameViewPath = [NSString stringWithFormat:@"%@/%@.ico", [CCUtility getDirectoryProviderStorageFileID:fileID], fileNameView];
|
|
|
|
-
|
|
|
|
- if ([[NSFileManager defaultManager] fileExistsAtPath:fileNameViewPath]) {
|
|
|
|
|
|
+ if ([[NSFileManager defaultManager] fileExistsAtPath:file]) {
|
|
|
|
|
|
completion(nil, 0);
|
|
completion(nil, 0);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
|
+ OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
|
+
|
|
[communication setCredentialsWithUser:_activeUser andUserID:_activeUserID andPassword:_activePassword];
|
|
[communication setCredentialsWithUser:_activeUser andUserID:_activeUserID andPassword:_activePassword];
|
|
[communication setUserAgent:[CCUtility getUserAgent]];
|
|
[communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
|
|
|
- [communication getRemoteThumbnailByServer:[_activeUrl stringByAppendingString:@"/"] ofFilePath:fileNamePath withWidth:width andHeight:height onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSData *thumbnail, NSString *redirectedServer) {
|
|
|
|
|
|
+ [communication getRemoteThumbnailByServer:[_activeUrl stringByAppendingString:@"/"] ofFilePath:[CCUtility returnFileNamePathFromFileName:metadata.fileName serverUrl:serverUrl activeUrl:_activeUrl] withWidth:width andHeight:height onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSData *thumbnail, NSString *redirectedServer) {
|
|
|
|
+
|
|
|
|
+ [thumbnail writeToFile:file atomically:YES];
|
|
|
|
|
|
- [thumbnail writeToFile:fileNameViewPath atomically:YES];
|
|
|
|
completion(nil, 0);
|
|
completion(nil, 0);
|
|
|
|
|
|
} failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
} failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|