1

我正在将视频和图像上传到远程服务器,并使用以下代码将它们转换为 nsdata:

ALAssetRepresentation *rep = [asset defaultRepresentation];
Byte *buffer = (Byte*)malloc(rep.size);
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];
//NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
NSData *imageData = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];

对于小型视频和图像,此代码运行良好,但对于大型视频或图像,应用程序崩溃。

4

1 回答 1

0

One of the solutions proposed is to partition those images and videos and upload them part by part.

  1. Open file to upload.
  2. read, let's say 5mb.
  3. put them on NSDATA. 4 upload it.
  4. clear NSDATA.

Repeat form point 2.

于 2013-10-10T14:51:05.470 回答