@@ -59,10 +59,10 @@ - (instancetype)init:(PHAsset *)phAsset error:(NSError *__autoreleasing *)error
5959 NSFileHandle *f = nil ;
6060 NSData *d = nil ;
6161 if (_fileSize > 16 * 1024 * 1024 ) {
62- f = [NSFileHandle fileHandleForReadingAtPath: self .filePath];
62+ f = [NSFileHandle fileHandleForReadingFromURL: [ NSURL fileURLWithPath: self .filePath] error: error ];
6363 if (f == nil ) {
6464 if (error != nil ) {
65- *error = [[NSError alloc ] initWithDomain: self .filePath code: kQNFileError userInfo: nil ];
65+ *error = [[NSError alloc ] initWithDomain: self .filePath code: kQNFileError userInfo: [*error userInfo ] ];
6666 }
6767 return self;
6868 }
@@ -113,7 +113,10 @@ - (void)close {
113113 if (_file != nil ) {
114114 [_file closeFile ];
115115 }
116- [[NSFileManager defaultManager ] removeItemAtPath: self .filePath error: nil ];
116+ // 如果是导出的 file 删除
117+ if (!self.hasRealFilePath && self.filePath ) {
118+ [[NSFileManager defaultManager ] removeItemAtPath: self .filePath error: nil ];
119+ }
117120 }
118121}
119122
@@ -134,7 +137,7 @@ - (void)getInfo {
134137 [self getImageInfo ];
135138 } else if (PHAssetMediaTypeVideo == self.phAsset .mediaType ) {
136139 // 1. 获取 video url
137- [self getVideoInfo ];
140+ // [self getVideoInfo];
138141
139142 // 2. video url 获取失败则导出文件
140143 if (self.filePath == nil ) {
@@ -167,7 +170,7 @@ - (void)getVideoInfo {
167170 options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat;
168171 // 不支持icloud上传
169172 options.networkAccessAllowed = NO ;
170-
173+
171174 dispatch_semaphore_t semaphore = dispatch_semaphore_create (0 );
172175 [[PHImageManager defaultManager ] requestAVAssetForVideo: self .phAsset options: options resultHandler: ^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
173176 if ([asset isKindOfClass: [AVURLAsset class ]]) {
0 commit comments