0
.net 서비스로 이미지 (jpg)를 업로드하고 있습니다. 나는 작은 이미지를 업로드하면 업로드가 잘 작동하지만 성공을 업로드 "큰"이미지 (이상 1 메가 또는 "큰"크기) 이미지를 보낼 때,하지만 이미지가 나는 시험이IOS 이미지를 .net 서비스로 업로드
처럼 보인다 컬을 통한 웹 서비스는 괜찮습니다.
아이디어가 있으십니까? 감사합니다 !!!!!!
내 업로드 코드는 다음과 같습니다
-(void)uploadJPEGImage:(NSString*)requestURL image:(UIImage*)image pictureName: (NSString*)pictureName {
NSURL *url = [[NSURL alloc] initWithString:requestURL];
NSMutableURLRequest *urequest = [NSMutableURLRequest requestWithURL:url];
[urequest setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[urequest setHTTPShouldHandleCookies:NO];
[urequest setTimeoutInterval:600];
NSData *postImageData = UIImageJPEGRepresentation(image, 0.9);
NSMutableData *body = [NSMutableData data];
[urequest setHTTPMethod:@"POST"];
//STEP2 Creating Boundary
// There are no rules as of the content of the boundary but as it must not occur in any of the parts of your message content is usually a randomly generated sequence of numbers, letters or combination of both in order to guarantee uniqueness and differentiate from any possible dictionary words.
NSString *boundary = @"---------------------------14737809831466499882746641449";
//Setting POST Header
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[urequest addValue:contentType forHTTPHeaderField:@"Content-Type"];
//STEP3 Begin boundary
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//STEP4 Adding additional parameters
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@.jpg\"\r\n",pictureName] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
//STEP5 Appending Image Data
[body appendData:[NSData dataWithData:postImageData]];
//STEP6 Closing boundary
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[urequest setHTTPBody:body];
//Set content length
NSString* postlength = [NSString stringWithFormat:@"%d", [body length]];
[urequest setValue:postlength forHTTPHeaderField:@"Content-Length"];
[url release];
NSURLConnection *conaux =[[NSURLConnection alloc] initWithRequest:urequest delegate:self startImmediately:NO];
self.connection = conaux;
[conaux release];
NSMutableData *auxdata = [[NSMutableData alloc] init];
self.receivedData = auxdata;
[auxdata release];
}
는
Content-Disposition 헤더에 파일 크기를 추가하려고 시도 했습니까? (즉, 크기 : <크기 (바이트)>). 나는 또한 Content-Length 헤더를 추가 할 수 있다고 생각한다. –
Content-length가 이미 header로 설정되었습니다. 콘텐츠 처리를 헤더로 이동하려고 시도하지만 오류가 계속됩니다. – pcambre