I need to know the type of file that I want to import. I can find out the type from the file name
for PHAsset you can use the following method:
Attachment *attachment = [[Attachment alloc] init];
attachment.assetIdentifierInternal = asset.localIdentifier;
attachment.descriptionInfo = [[NSProcessInfo processInfo] globallyUniqueString];
attachment.isPhoto = YES;
attachment.isDocument = NO;
NSArray *resources = [PHAssetResource assetResourcesForAsset:asset];
NSString *fileName = ((PHAssetResource *)resources[0]).originalFilename;
attachment.format = [fileName pathExtension];
is there anything similar for DocumentPicker?
descriptInfo shows without problems. name - nil.
Setter for name:
- (void)setName:(NSString *)name {
_name = name;
self.format = [name pathExtension];
CFStringRef fileExtension = (__bridge CFStringRef) self.format;
CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
self.isPhoto = UTTypeConformsTo(fileUTI, kUTTypeImage);
self.isDocument = UTTypeConformsTo(fileUTI, kUTTypeData); }
After a little searching, I found the solution myself. Name and format is easy to track by URL. Like This
attachment.fileUrlInternal = url;
attachment.format = [attachment.fileUrlInternal pathExtension];
attachment.name = url.lastPathComponent;