What is the best way to upload videos from gallery using Photos framework? Before I used ALAssetRepresentation and next method:
- (NSUInteger)getBytes:(uint8_t *)buffer fromOffset:(long long)offset length:(NSUInteger)length error:(NSError **)error;
this allowed to upload file without first copying it to app temp directory. Don’t see any alternatives in Photos framework. Only way seems to use AVAssetExportSession -> export to local directory -> upload, but this requires additional storage space (could be a problem, if video is too big)
Seems the only valid way is to request
AVAsset
fromPHImageManager
, and check if returned asset isAVURLAsset
. In this case URL can be used to directly access file and get needed chunk of bytes:This will not work with slow motion videos, because
AVComposition
instead ofAVURLAsset
is returned. Possible solution is to usePHVideoRequestOptionsVersionOriginal
video file version:And to get fullsize image url: