danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.59k forks source link

Android and camera capture #1723

Open ghost opened 8 years ago

ghost commented 8 years ago

Strange behaviour on android - when capturing image from camera, most of the times the FileReader receives an empty object "data:" and there is an exeption about an offset of the data view. It makes sense because it takes some time to write the image to the storage. It DOES NOT happen when choosing image from gallery, well, the file already written to storage.

Also, in iOS all is good.

I created a small workaround - making a timeout of few seconds before applying the Exif fix:

if (upload.attrGetter('ngfFixOrientation', attr, scope) && upload.isExifSupported()) {
          $timeout(function () {
            applyExifRotations(valids, attr, scope).then(function () {
              resizeAndUpdate();
            });
          }, 10000);

        } else {
          resizeAndUpdate();
        }

but it's a hack.... so, is there a way to fix this issue? any idea? Thanks!

georgeonofrei commented 8 years ago

It's probably not related, but I also have a bit of a weird behavior with the camera. When trying to upload from camera, the model is undefined. I hooked to the ngf-change and the $file contains a blob URL -> what should i do with that? Or how can I make the the model filled with the right data?