From ed307cf165ee9df8a8f37abaa92cba87afe61d31 Mon Sep 17 00:00:00 2001 From: TanaseButcaru Date: Tue, 16 Feb 2016 15:54:02 +0200 Subject: [PATCH 1/2] new MediaFile() - fix wrong property name for localURL --- www/MediaFile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/MediaFile.js b/www/MediaFile.js index 1bc600ff..03c15a25 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,7 +45,7 @@ utils.extend(MediaFile, File); * @param {Function} errorCB */ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) { - if (typeof this.fullPath === "undefined" || this.fullPath === null) { + if (typeof this.localURL === "undefined" || this.localURL === null) { errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); } else { exec(successCallback, errorCallback, "Capture", "getFormatData", [this.localURL, this.type]); From 5442225cbcf7760407479b142666d04ad7600e2a Mon Sep 17 00:00:00 2001 From: TanaseButcaru Date: Tue, 16 Feb 2016 17:37:27 +0200 Subject: [PATCH 2/2] new MediaFile() - fix localURL / fullPath + iOS path check --- www/MediaFile.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/www/MediaFile.js b/www/MediaFile.js index 03c15a25..6910adda 100644 --- a/www/MediaFile.js +++ b/www/MediaFile.js @@ -45,10 +45,20 @@ utils.extend(MediaFile, File); * @param {Function} errorCB */ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) { - if (typeof this.localURL === "undefined" || this.localURL === null) { + + //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]); } };