Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readOrientation() uses Blob.slice(), but isExifSupported does not check if Blob.slice() exists #1391

Closed
mourukoski opened this issue Feb 29, 2016 · 4 comments
Labels

Comments

@mourukoski
Copy link

I'm hitting this problem on a Samsung Galaxy S3 with Android Browser 4 (the default browser) when ngf-fix-orientation="true" is used. Version 12.0.1.

isExifSupported() is used in validate() to see if the browser supports Blob datatype/object before EXIF rotation, but there is no check to see if Blob.slice() exists (used in readOrientation()).

According to MDN[1] Blob.slice() used to be vendor prefixed in older browser versions.

I expect isExifSupported() check to fail if Blob.slice() is missing. I can always polyfill Blob with vendor version of .slice(), but in my opinion the library should check if the function doesn't exist because there is a chance it doesn't.

Locally I can fix this issue by adding isResumeSupported() to isExifSupported() because it checks for Blob.slice()'s existance.

TypeError: Object #<File> has no method 'slice'
    at upload.readOrientation (http://localhost:8000/js/dep/angular/ng-file-upload.js:2098:27)
    at upload.applyExifRotation (http://localhost:8000/js/dep/angular/ng-file-upload.js:2154:12)
    at http://localhost:8000/js/dep/angular/ng-file-upload.js:466:50
    at Object.m [as forEach] (http://localhost:8000/js/dep/angular/min/angular.min.js:7:322)
    at applyExifRotations (http://localhost:8000/js/dep/angular/ng-file-upload.js:464:13)
    at http://localhost:8000/js/dep/angular/ng-file-upload.js:652:11
    at http://localhost:8000/js/dep/angular/min/angular.min.js:120:182
    at n.$eval (http://localhost:8000/js/dep/angular/min/angular.min.js:134:493)
    at n.$digest (http://localhost:8000/js/dep/angular/min/angular.min.js:132:9)
    at n.$apply (http://localhost:8000/js/dep/angular/min/angular.min.js:135:269)

[1] https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice

@danialfarid
Copy link
Owner

You are probably using an older version. upgrade to the latest.

@mourukoski
Copy link
Author

Unfortunately Upload.version says 12.0.1. I made a fork from one of your own examples. I added ngf-fix-orientation="true" parameter to the directive call, and added a simple delete Blob.prototype.slice; to be able to hit this error on a browser which fully implements Blob (without using any vendor prefixes).

http://jsfiddle.net/b2gqa5go/2/

TypeError: file.slice is not a function
    at upload.readOrientation (ng-file-upload.js:2098)
    at upload.applyExifRotation (ng-file-upload.js:2154)
    at ng-file-upload.js:466
    at Object.forEach (angular.js:336)
    at applyExifRotations (ng-file-upload.js:464)
    at ng-file-upload.js:652
    at processQueue (angular.js:14634)
    at angular.js:14650
    at Scope.$eval (angular.js:15916)
    at Scope.$digest (angular.js:15727)

@danialfarid danialfarid added the bug label Mar 8, 2016
@danialfarid
Copy link
Owner

Remove blob.slice() from line 2098 if it is not available.

@danialfarid
Copy link
Owner

Fixed at 12.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants