我想在服务器上上传我的大图。
是否可以将它们分块转换并上传到服务器上?
这是我上传图片的代码我如何在块中发送图片?
NSDateFormatter* df = [[NSDateFormatter alloc]init];
[df setDateFormat:@"MM/dd/yyyy"];
NSString *result = [df stringFromDate:assetDate];
NSTimeInterval timeInterval = [assetDate timeIntervalSince1970];
ALAssetRepresentation *rep = [temp defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
StrPath = [StrPath stringByAppendingFormat:@"%d.%@",(int)timeInterval,strImageType];
//UIImage *image = [UIImage imageWithCGImage:[rep fullResolutionImage]];
UIImage *image =[UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];
//------------------ metadata -------------------------------------------------------
NSDictionary *imageMetadata = [rep metadata];
NSString *strOrt=[NSString stringWithFormat:@"%@",[imageMetadata valueForKey:@"Orientation"]];
NSData *dataObj = nil;
dataObj = UIImageJPEGRepresentation(image, 1.0);
NSString* StrFileData = [Base64 encode:dataObj];
NSString* strFileHash = [dataObj md5Test];
NSMutableDictionary *DictRequest = [[NSMutableDictionary alloc]init];
[DictRequest setObject:srtprefSessionId forKey:@"SessionId"];
[DictRequest setObject:StrPath forKey:@"Path"];
[DictRequest setValue:[NSNumber numberWithBool:isTrash] forKey:@"UploadDirectlyToTrashbin"];
[DictRequest setObject:StrFileData forKey:@"FileData"];
[DictRequest setObject:strFileHash forKey:@"FileHash"];
[DictRequest setObject:result forKey:@"DateCreated"];
BOOL isNULL = [self stringIsEmpty:strOrt];
if(!isNULL)
{
//[DictRequest setObject:strOrt forKey:@"Orientation"];
}
NSString *jsonString = [DictRequest JSONRepresentation];
NSString *strUrl=[NSString stringWithFormat:@"%@",FileUpload_URL];
NSURL *url1=[NSURL URLWithString:strUrl];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url1];
[request setTimeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
NSData *postData = [jsonString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
[request setHTTPBody:postData];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
if(theConnection)
[self Set2Defaults];
theConnection = [[NSURLConnection alloc]initWithRequest:request delegate:self];
[SVProgressHUD dismiss];
if(theConnection)
webData = [NSMutableData data];
else
NSLog(@"Connection Failed !!!");