cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Mullins (JIRA)" <>
Subject [jira] [Created] (CB-8546) MimeType of camera (or otherwise) file in IOS
Date Wed, 25 Feb 2015 17:46:04 GMT
Mike Mullins created CB-8546:

             Summary: MimeType of camera (or otherwise) file in IOS
                 Key: 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

Would love to be able to get actual file mimetype (not just an extension guess) on locally
uploaded files in cordova on ios. 

	window.resolveLocalFileSystemURL(imageData, function(fileEntry) {
				fileEntry.file(function(filedata) {
			}, errorCB2); 

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!

 // can't easily get the mimetype unless create URL, send request and read response so skipping

- (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void (^)(CDVPluginResult
    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];

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message