diff --git a/www/MediaFile.js b/www/MediaFile.js index 1bc600ff..6910adda 100644 --- a/www/MediaFile.js +++ b/www/MediaFile.js @@ -27,7 +27,7 @@ var utils = require('cordova/utils'), * Represents a single file. * * name {DOMString} name of the file, without path information - * fullPath {DOMString} the full path of the file, including the name + * localURL {DOMString} the full path of the file, including the name * type {DOMString} mime type * lastModifiedDate {Date} last modified date * size {Number} size of the file in bytes @@ -45,10 +45,20 @@ utils.extend(MediaFile, File); * @param {Function} errorCB */ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) { + + //case when MediaFile is manually created, not a result of media-capture + if (typeof this.fullPath === "undefined" && this.localURL !== null) { + this.fullPath = this.localURL; + + if (device.platform.toLowerCase() == 'ios' && this.fullPath.indexOf('file://') != -1) { + this.fullPath = this.fullPath.replace('file://', ''); + } + } + if (typeof this.fullPath === "undefined" || this.fullPath === null) { errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); } else { - exec(successCallback, errorCallback, "Capture", "getFormatData", [this.localURL, this.type]); + exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]); } };