ios - Upload big video from PhotoLibrary to server -


i have problem uploading big video asset server photolibrary.

i asset data described here, export video local document, , upload.

but when upload big video (2 minutes , 300mb or more in size), method causes crash , got no reason nor any information.

i use webdav upload files this:

    // set 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 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]; 

when code reache line:

self.currentfilestream = [nsinputstream inputstreamwithfileatpath:self.filepath]; [request sethttpbodystream:currentfilestream];

or:

[request sethttpbody:[nsdata datawithcontentsoffile:self.filepath]]; 

it crashed.

do have suggestion?

thanks.

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

edit: crash @ sethttpbody: or sethttpbodystream: think it's memory leak or something.

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

edit2: decide compress video, video data current method large(more 300mb), find use uiimagepickercontroller select same video, 30mb; compress help; i'll try uivideoeditorcontroller, , post result soon;

completed. solution try compress big video small file;

1.just before, export video asset tmp directory;

2.use uivideoeditorcontroller compress video file;

3.just upload compressed file code post.

that's all.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -