[ 
https://issues.apache.org/jira/browse/CB-12515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15890678#comment-15890678
 ] 

Kerri Shotts commented on CB-12515:
-----------------------------------

I just caught on that you're using a third-party JS Library for uploading. ES5 
offers no mechanism for changing the internal class property, which is what 
using {{Object.prototype.toString.call}} references. As such, when Cordova 
creates a File class and then instantiates an object from it, the internal 
class remains "Object", and there's no way to override that. ES2015+ has 
possibilities, but Cordova must remain compatible with ES5 for now.

I would suggest filing an issue with the third-party plugin indicating that 
their type checking fails in this case. Personally, I'd prefer some duck typing 
here: that is, check if the passed object has the properties/methods you 
expect, and if it does, it's probably a File. 

Alternatively, consider using other wrappers that don't rely on this kind of 
type checking, or interface with the File & File Transfer plugins directly.

Since there's nothing we can do, I'm closing the issue.

> Object.prototype.toString.call(file) returns [object Object] instead of 
> [object File]
> -------------------------------------------------------------------------------------
>
>                 Key: CB-12515
>                 URL: https://issues.apache.org/jira/browse/CB-12515
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>            Reporter: Alexander Broekhuis
>
> I'm trying to use the File plugin in combination with FineUploader. 
> FineUploader uses the File API and tests if a passed in object is a file 
> using the following call:
> Object.prototype.toString.call(file) === "[object File]"
> But the File retrieved from a FileEntry using entry.file(function(file) { ... 
> }); is not seen as a file since the toString.call returns [object Object].



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to