danialfarid / ng-file-upload

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

ngf-resize will duplicate uploads and drop some others #1999

Open sontran1 opened 6 years ago

sontran1 commented 6 years ago

Hi, I have a very hard headache issue with ngf-resize, it took me hours to figure out which part produces it. It is ngf-resize option. Seen in ng-file-upload 10, 12. Haven't tried other versions.

Code: Angular:

        Upload.upload({
            url         : $window.location.protocol + '//' + $window.location.host + api.createPost,
            data        : {
                files       : files, 
                postContent : $scope.createPost.data },
            arrayKey    : '',
        }).then(function(resp) { ... }, function(err) { ... }

HTML:

<input name="file" type="file" ngf-select ng-model="files" ngf-multiple="true" ngf-resize="{quality: .3}" ngf-fix-orientation="true" ngf-pattern="'.jpeg,.jpg'" ng-click="picLoading()">

Issue: I upload 5 pics, say pic1, pic2, pic3, pic4, pic5. Server receive pic1, pic1, pic3, pic3, pic4 or pic2, pic3, pic3, pic4, pic4. Very randomly, can be in different sets. Server always receive enough number of pics, the issue is pics gets duplicated and dropped.

The issue gets worse if I add more resize options. ex: ngf-resize="{width:960,quality:0.3}"

When I remove ngf-resize="{quality: .3}" part, upload works fine.

Please help to fix. My server is NodeJS with Multer. It works fine with any upload from Postman. Example output from server: screen shot 2017-09-06 at 10 47 19 pm

alok-agarwal commented 6 years ago

@sontran1 Did you manage to get a solution to it ?

I am not using ngf-reszie, but still at times some images get dropped and one if it is duplicated ?

sonttran commented 6 years ago

@alok-agarwal : yes, I did find a solution. Don't use timestamp on the image name. The machine speed is too fast and it can stamp several images at the same time, causing images got duplicated.