큰 비디오 자산을 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
을 시도하고 조만간 내 결과를 게시 할 예정입니다. 내가 서버에 이미지를 업로드하고 게시, 다음
답장을 보내 주셔서 감사합니다. 나는 그것을 읽었지만 아무런 해결책도 찾지 못했다. 나는 내가 설명한 것처럼 WebDAV를 통해 PhotoLibrary에서 서버로 비디오 (작은 크기)/이미지 자산을 성공적으로 업로드 할 수 있음을 의미합니다. 그러나 큰 크기의 비디오 자산이 오면 충돌합니다. PhotoLibrary에서 큰 크기의 비디오 자산을 업로드 할 수있는 방법이 있습니까? – traximus
당신은 comprase 크기로 그 자산의 zip 파일을 만들 수 있습니다. 그런 다음 업로드 할 수 있습니다. 또는 데이터를 작은 패킷으로 나누어 업로드 할 수 있습니다. –
UIVideoEditorController로 비디오 에셋을 압축하고 업로드합니다.데이터를 작은 패킷으로 나눌려고했지만 서버가이 작은 파일을 하나의 파일로 결합하는 것을 지원하지 않습니다. 고마워요, 똑같은, 기원합니다 – traximus