5

Issue: Error: FileConstructor is not a constructor (evaluating 'new File([blob], "filename.png")')

I saw this question Alternative for File() constructor for safari but there weren't any alternatives worth looking at.

Is there anyway to work around this using Ionic Framework on IOS?

Javascript

a = Base64 image.

 var blob = new Blob([a], {type: 'image/png'});

        console.log(blob);
        $scope.Issue14 = blob;

       var nfile = new File([blob], "filename.png");

        console.log(nfile);
        $scope.Issue15 = nfile;

       var _file = nfile;

        console.log(_file);
        $scope.Issue16 =  _file;

        $scope.Images.push({"img": _file});  

1 Answer 1

4

I'm facing the same issue with File and Safari. After some research I found a solution that seems to work for me... hope it will be useful for you:

Instead of using new File, i append name and lastModifiedDate fields to the blob.

 blob.name = "filename.png";
 blob.lastModifiedDate = new Date();

It is not a file, but you can use it like it was...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.