From d79bb6fe6a8762bb0b35b673142213c84933183b Mon Sep 17 00:00:00 2001 From: lilthree <87437904@qq.com> Date: Sat, 18 Nov 2017 15:13:43 +0800 Subject: [PATCH] code refactor --- Pod/Classes/SeafUploadFile.m | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/Pod/Classes/SeafUploadFile.m b/Pod/Classes/SeafUploadFile.m index 0dc35a81..1953a4df 100644 --- a/Pod/Classes/SeafUploadFile.m +++ b/Pod/Classes/SeafUploadFile.m @@ -482,29 +482,14 @@ - (void)upload:(SeafConnection *)connection repo:(NSString *)repoId path:(NSStri Debug("upload Local decrypt %@ by block: %lld", self.name, _filesize); return [self uploadLargeFileByBlocks:repo path:uploadpath]; } - NSString* upload_url = [NSString stringWithFormat:API_URL"/repos/%@/upload-", repoId]; - if (byblock) - upload_url = [upload_url stringByAppendingString:@"blks-link/"]; - else - upload_url = [upload_url stringByAppendingString:@"link/"]; - + NSString* upload_url = [NSString stringWithFormat:API_URL"/repos/%@/upload-link/", repoId]; upload_url = [upload_url stringByAppendingFormat:@"?p=%@", uploadpath.escapedUrl]; Debug("upload file size: %lld %@ %@", _filesize, self.lpath, upload_url); [connection sendRequest:upload_url success: ^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSString *url = [JSON stringByAppendingString:@"?ret-json=true"]; Debug("Upload file %@ %@, %@ overwrite=%d, byblock=%d, delegate%@\n", self.name, url, uploadpath, self.overwrite, byblock, _delegate); - if (byblock) { - NSMutableArray *blockids = [[NSMutableArray alloc] init]; - NSMutableArray *paths = [[NSMutableArray alloc] init]; - if ([self chunkFile:self.lpath repo:repo blockids:blockids paths:paths]) { - [self uploadByBlocks:connection url:url uploadpath:uploadpath blocks:blockids paths:paths update:self.overwrite]; - } else { - [self finishUpload:NO oid:nil]; - } - } else { - [self uploadByFile:connection url:url path:uploadpath update:self.overwrite]; - } + [self uploadByFile:connection url:url path:uploadpath update:self.overwrite]; } failure: ^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON, NSError *error) {