Size property differs on creating file object from existing one - javascript, plupload

89 Views Asked by At

I am trying to create a new file object from the files array parameter of Plupload's FilesAdded method. But the resulting new file object has a size property value way lesser than the original.
That is,
the actual object in files[0] has size:56834
copiedFileObject has size:15
The following is a code snippet to illustrate the problem I am facing.

uploader.bind('FilesAdded', function(up, files) {       
    var copiedFileObject = new File([files[0]],files[0].name,{type:"application/pdf"});
    var pdf_url = URL.createObjectURL(copiedFileObject);
    //File[0] object has size:56834 but
    //copiedFileObject object has size: 15
    console.log(pdf_url);
});

May I know how I can create a copy of native file object in this plupload plugin?
Actual usage scenario: A drag and drop file upload feature.

1

There are 1 best solutions below

0
On BEST ANSWER

I updated the plupload plugin to version 2.1.2 and then used the getNative method to create a copy of the native file object. This solved the size difference as well.

uploader.bind('FilesAdded', function(up, files) {       
    var copiedFileObject = files[0].getNative();
    var pdf_url = URL.createObjectURL(copiedFileObject);
    console.log(pdf_url);
});