[ https://issues.apache.org/jira/browse/CB-8546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mike Mullins updated CB-8546: ----------------------------- Summary: MimeType undefined on files in IOS (was: MimeType of camera (or otherwise) file in IOS) > MimeType undefined on files in IOS > ---------------------------------- > > Key: CB-8546 > URL: https://issues.apache.org/jira/browse/CB-8546 > Project: Apache Cordova > Issue Type: New Feature > Components: iOS, Plugin File > Affects Versions: 4.0.0 > Environment: OS: Mac OS X Yosemite > Node Version: v0.12.0 > Cordova CLI: 4.2.0 > Xcode version: Xcode 6.1.1 Build version 6A2008a > ios-sim version: 3.1.1 > Reporter: Mike Mullins > Labels: filesystem, ios8, mime-type, mimeType, upload > > Would love to be able to get actual file mimetype (not just an extension > guess) on locally uploaded files in cordova on ios. > <pre> > window.resolveLocalFileSystemURL(imageData, function(fileEntry) { > fileEntry.file(function(filedata) { > console.log(filedata); > }); > }, errorCB2); > </pre> > returns type: nill > i've noticed in the CDVlocalfilesystem.m file that this appears to be of > note, would love to see it pushed up the list a bit! > <pre> > // can't easily get the mimetype unless create URL, send request and read > response so skipping > </pre> > <pre> > - (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void > (^)(CDVPluginResult *))callback > { > NSString *path = [self filesystemPathForURL:localURL]; > CDVPluginResult *result; > NSFileManager* fileMgr = [[NSFileManager alloc] init]; > NSError* __autoreleasing error = nil; > NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:path > error:&error]; > if (fileAttrs) { > // create dictionary of file info > NSMutableDictionary* fileInfo = [NSMutableDictionary > dictionaryWithCapacity:5]; > [fileInfo setObject:localURL.fullPath forKey:@"fullPath"]; > [fileInfo setObject:@"" forKey:@"type"]; // can't easily get the > mimetype unless create URL, send request and read response so skipping > [fileInfo setObject:[path lastPathComponent] forKey:@"name"]; > // Ensure that directories (and other non-regular files) report size > of 0 > unsigned long long size = ([fileAttrs fileType] == NSFileTypeRegular > ? [fileAttrs fileSize] : 0); > [fileInfo setObject:[NSNumber numberWithUnsignedLongLong:size] > forKey:@"size"]; > NSDate* modDate = [fileAttrs fileModificationDate]; > if (modDate) { > [fileInfo setObject:[NSNumber numberWithDouble:[modDate > timeIntervalSince1970] * 1000] forKey:@"lastModifiedDate"]; > } > result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK > messageAsDictionary:fileInfo]; > </pre> -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org