I am not able to retrieve NSData from the url that I get from ALAsset
Below is the code I tried:- I always get NSData as nil.
NSData *webData = [NSData dataWithContentsOfURL:[asset defaultRepresentation].url];
I also tried something like this
NSData *webData1 = [NSData dataWithContentsOfURL:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]]];
The url that I get from the ALAsset:-
assets-library://asset/asset.MOV?id=1000000116&ext=MOV
I have tried this below link which works but I need to unnecessary write to a temp location which is very time consuming.
Any hint in right direction would be highly appreciated.
Waiting for your replies
try this code:-
ALAssetRepresentation *rep = [asset defaultRepresentation];
Byte *buffer = (Byte*)malloc((NSUInteger)rep.size);
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:(NSUInteger)rep.size error:nil];
NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];