2013-03-25 2 views
0

큰 비디오 자산을 PhotoLibrary에서 서버로 업로드하는 데 문제가 있습니다.PhotoLibrary에서 서버로 큰 비디오 업로드

자산 데이터를 described here으로 가져오고 비디오를 로컬 문서로 내 보낸 다음 업로드하십시오.

큰 비디오 (2 분, 약 300MB 이상)를 업로드하면이 방법으로 인해 충돌이 발생하며 아무런 이유도없고 정보도 없습니다.

난 그냥 이런 식으로 파일을 업로드 할 수 webDAV를 사용

self.currentFileStream = [NSInputStream inputStreamWithFileAtPath:self.filepath]; [request setHTTPBodyStream:currentFileStream];

OR : 그것은 추락

[request setHTTPBody:[NSData dataWithContentsOfFile:self.filepath]]; 

코드이 줄을 reache

// Set up credentials 
    NSURLCredential *userCredentials = [NSURLCredential credentialWithUser:username 
                    password:password 
            persistence:NSURLCredentialPersistenceForSession]; 
    NSURLProtectionSpace *space = [[NSURLProtectionSpace alloc] initWithHost:host 
                     port:80 
                    protocol:@"http" 
                     realm:@" webDAV" 
                 authenticationMethod:nil]; 
    [[NSURLCredentialStorage sharedCredentialStorage] setCredential:userCredentials forProtectionSpace:space]; 
    [space release]; 

    // Create the request 
    NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url]; 
    [request setHTTPMethod:@"PUT"]; 
    [request setValue:[self mimetypeForFile:self.filepath] forHTTPHeaderField:@"Content-Type"]; 
    NSNumber *contentLength = (NSNumber *) [[[NSFileManager defaultManager] 
              attributesOfItemAtPath:self.filepath error:NULL] 
              objectForKey:NSFileSize]; 
    [request setValue:[contentLength description] forHTTPHeaderField:@"Content-Length"]; 

    if (self.useStreaming) 
    { 
     if (self.currentFileStream!=nil) 
     { 
      [self.currentFileStream close], self.currentFileStream = nil; 
     } 
     self.currentFileStream = [NSInputStream inputStreamWithFileAtPath:self.filepath]; 

     if (currentFileStream!=nil) 
     { 
      [request setHTTPBodyStream:currentFileStream]; 
     } 
     else 
     { 
      [request setHTTPBody:[NSData dataWithContentsOfFile:self.filepath]]; 
     } 
    } 
    else 
    { 
     [request setHTTPBody:[NSData dataWithContentsOfFile:self.filepath]]; 
    } 



    NSURLConnection* conn = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 

    if (self.currentConnection!=nil) 
    { 
     self.currentConnection = nil; 
    } 
    self.currentConnection = conn; 
    [conn release]; 
    [self.currentConnection start]; 

.

의견이 있으십니까?

감사합니다.

========================

편집 : 그것은 그래서는 메모리 누수에 대해 생각 setHTTPBody: 또는 setHTTPBodyStream:에서 충돌 또는 뭔가.

================

EDIT2 :가 지금은 현재의 방법이 너무 크면으로 내가 (3백메가바이트 이상) 비디오 데이터를 얻을, 비디오를 압축하기로 결정 ,하지만 난 UIImagePickerController 같은 비디오를 선택, 그냥 30mb를 찾을, 그래서 압축 도움말입니다; UIVideoEditorController을 시도하고 조만간 내 결과를 게시 할 예정입니다. 내가 서버에 이미지를 업로드하고 게시, 다음

답변

1

게시 할 수 있습니다. 해결책은 큰 파일을 작은 파일로 압축하려고 시도하는 것입니다.

1. 전에처럼, tmp 디렉토리에 비디오 자산을 내 보냅니다.

2.0 비디오 파일을 압축하기 위해 UIVideoEditorController;

3. 내가 게시 한 코드처럼 압축 된 파일을 업로드하십시오.

그게 전부입니다.

0

검사 대신 이미지의 당신은 당신의 비디오 완료 Uploading Image via POST in Objective C

+0

답장을 보내 주셔서 감사합니다. 나는 그것을 읽었지만 아무런 해결책도 찾지 못했다. 나는 내가 설명한 것처럼 WebDAV를 통해 PhotoLibrary에서 서버로 비디오 (작은 크기)/이미지 자산을 성공적으로 업로드 할 수 있음을 의미합니다. 그러나 큰 크기의 비디오 자산이 오면 충돌합니다. PhotoLibrary에서 큰 크기의 비디오 자산을 업로드 할 수있는 방법이 있습니까? – traximus

+0

당신은 comprase 크기로 그 자산의 zip 파일을 만들 수 있습니다. 그런 다음 업로드 할 수 있습니다. 또는 데이터를 작은 패킷으로 나누어 업로드 할 수 있습니다. –

+0

UIVideoEditorController로 비디오 에셋을 압축하고 업로드합니다.데이터를 작은 패킷으로 나눌려고했지만 서버가이 작은 파일을 하나의 파일로 결합하는 것을 지원하지 않습니다. 고마워요, 똑같은, 기원합니다 – traximus

관련 문제