Meteor-Community-Packages / Meteor-CollectionFS

Reactive file manager for Meteor
MIT License
1.05k stars 237 forks source link

Multiple file upload failure #533

Open flamedmg opened 9 years ago

flamedmg commented 9 years ago

I'm getting following error during uploading multiple files: PUT http://localhost:3000/cfs/files/lectureFiles/DC63HyBBaMDejois4?chunk=0&file…VG9rZW4iOiJ0NVJaSGQ3UElFdElHSEgyLWk5TGNFUWduVGY5Q3FTeXIyVm9YblExYU1jIn0%3D 404 (Not Found) power-queue.js:486 Error: "Queue" failed [404] Not Found [404] [undefined], Error: failed [404] Not Found [404] [undefined]

The first file is uploaded fine, but next one - fails. Code that i'm using to upload file is as follows:

var dropZone = this.find('#drop-zone');
var uploadForm = this.find('#js-upload-form');

var self = this.data;

var startUpload = function (files) {

    for(var a=0; a < files.length; a++) {
        var file = files[0];

        LectureFiles.insert(file, function (err, fileObj) {
            if (err) {
                alert(err);
                return;
            }

            console.dir(fileObj);

        });
    }
};

uploadForm.addEventListener('submit', function (e) {
    var uploadFiles = document.getElementById('js-upload-files').files;
    e.preventDefault();

    startUpload(uploadFiles)
});

dropZone.ondrop = function (e) {
    e.preventDefault();
    this.className = 'upload-drop-zone';

    startUpload(e.dataTransfer.files)
};

dropZone.ondragover = function () {
    this.className = 'upload-drop-zone drop';
    return false;
};

dropZone.ondragleave = function () {
    this.className = 'upload-drop-zone';
    return false;
}

On server i see something like this:

=> Started proxy.
=> Started MongoDB.
I20150208-22:16:57.597(2)? => GraphicsMagick found

I20150208-22:16:57.787(2)? Meteor._wrapAsync has been renamed to Meteor.wrapAsync

I20150208-22:16:57.855(2)? FileWorker ADDED - calling deleteChunks for 2gRretHxoH7SKPnYQ

I20150208-22:16:57.861(2)? TempStore is mounted on storage.gridfs

I20150208-22:16:57.863(2)? FileWorker ADDED - calling deleteChunks for FkPuYcwG8HJokzckc

I20150208-22:16:57.865(2)? FileWorker ADDED - calling deleteChunks for ECgcBr6GzfFAoTvbS

I20150208-22:16:57.866(2)? FileWorker ADDED - calling deleteChunks for CtBugLTrXeNvLYMoc

I20150208-22:16:57.867(2)? FileWorker ADDED - calling deleteChunks for 44ZKTQ3X6aDceMxbF

I20150208-22:16:57.868(2)? FileWorker ADDED - calling deleteChunks for Fcd85MS8QLpdokNYW

I20150208-22:16:57.869(2)? FileWorker ADDED - calling deleteChunks for ZQtrS5YfPbqqKw3Qt

I20150208-22:16:57.870(2)? FileWorker ADDED - calling deleteChunks for QcBAabzL6PEFJvCMq

I20150208-22:16:57.870(2)? FileWorker ADDED - calling deleteChunks for bRtNSRshuRWJvxhb4

I20150208-22:16:57.871(2)? FileWorker ADDED - calling deleteChunks for GRpMs8bBcN4r4pk8a

I20150208-22:16:57.872(2)? FileWorker ADDED - calling deleteChunks for HWaEzWoiKhufxhufd

I20150208-22:16:57.873(2)? FileWorker ADDED - calling deleteChunks for 59WnAuy2mj8qXkX5z

I20150208-22:16:57.874(2)? FileWorker ADDED - calling deleteChunks for YJWrtu8aiuDJqtfeE

I20150208-22:16:57.875(2)? FileWorker ADDED - calling deleteChunks for TgaXArc3j4bEkiX9C

I20150208-22:16:57.877(2)? FileWorker ADDED - calling deleteChunks for 7sePrMJgw5sfgKs9p

I20150208-22:16:57.878(2)? FileWorker ADDED - calling deleteChunks for ACdo6wCXFaRYpzcda

I20150208-22:16:57.878(2)? FileWorker ADDED - calling deleteChunks for AKCsGvostwK3oeuSu

I20150208-22:16:57.880(2)? FileWorker ADDED - calling deleteChunks for FNroGTx6FBC3dXouh

I20150208-22:16:57.881(2)? FileWorker ADDED - calling deleteChunks for MRQa9y9xTbbjy2MQq

I20150208-22:16:57.882(2)? FileWorker ADDED - calling deleteChunks for EuvnsDHBfjF38363N

I20150208-22:16:57.883(2)? FileWorker ADDED - calling deleteChunks for sJmN6zN9c6XgMN4Nn

I20150208-22:16:57.924(2)? FileWorker ADDED - calling deleteChunks for ds9zKoRTpMjBtKMTE

I20150208-22:16:57.925(2)? FileWorker ADDED - calling deleteChunks for bMTgYzEHpi5hBTG6k

I20150208-22:16:57.926(2)? FileWorker ADDED - calling deleteChunks for FfMHbcnRwYxwA5YhT

I20150208-22:16:57.927(2)? FileWorker ADDED - calling deleteChunks for CJsBBMFpSHGop74mJ

I20150208-22:16:57.946(2)? FS.HTTP.unmount:

I20150208-22:16:57.946(2)? {}

I20150208-22:16:57.946(2)? Registered HTTP method URLs:

I20150208-22:16:57.947(2)? /cfs/files/:collectionName/:id/:filename

I20150208-22:16:57.947(2)? /cfs/files/:collectionName/:id

I20150208-22:16:57.947(2)? /cfs/files/:collectionName

=> Started your app.

=> App running at: http://localhost:3000/
I20150208-22:17:06.850(2)? Inserting lectureFile:

I20150208-22:17:06.851(2)? [Function]

I20150208-22:17:06.923(2)? token: eyJhdXRoVG9rZW4iOiJ0NVJaSGQ3UElFdElHSEgyLWk5TGNFUWduVGY5Q3FTeXIyVm9YblExYU1jIn0=

I20150208-22:17:06.927(2)? HTTP PUT (update) handler received chunk:  0

I20150208-22:17:06.927(2)? GET FILERECORD: qDGwcT2AKiofibSB8

I20150208-22:17:06.928(2)? Inserting lectureFile:

I20150208-22:17:06.929(2)? [Function]

I20150208-22:17:06.944(2)? createWriteStream _tempstore, internal: true

I20150208-22:17:06.944(2)? createWriteStreamForFileKey _tempstore

I20150208-22:17:06.975(2)? SA GridFS - DONE!

I20150208-22:17:06.976(2)? -----------STORED STREAM _tempstore

I20150208-22:17:06.976(2)? -----------CLOSE STREAM _tempstore

I20150208-22:17:06.979(2)? TempStore progress: Received 1 of 1 chunks for 113187.jpg

I20150208-22:17:06.979(2)? UPDATE: {"$set":{"uploadedAt":"2015-02-08T20:17:06.978Z"},"$unset":{"chunkCount":1,"chunkSum":1,"chunkSize":1}}

I20150208-22:17:06.979(2)? 113187.jpg was successfully uploaded. You are seeing this informational message because you enabled debugging and you have not 
defined any listeners for the "uploaded" event on the lectureFiles collection.

I20150208-22:17:06.986(2)? FileWorker ADDED - calling saveCopy lectures for qDGwcT2AKiofibSB8

I20150208-22:17:06.986(2)? saving to store lectures

I20150208-22:17:06.986(2)? createWriteStream lectures, internal: false

I20150208-22:17:06.987(2)? createWriteStreamForFileKey lectures

I20150208-22:17:06.987(2)? FS.TempStore creating read stream for qDGwcT2AKiofibSB8

I20150208-22:17:06.989(2)? createReadStream _tempstore

I20150208-22:17:06.989(2)? createReadStreamForFileKey _tempstore

I20150208-22:17:06.998(2)? SA GridFS - DONE!

I20150208-22:17:06.998(2)? -----------STORED STREAM lectures

I20150208-22:17:06.998(2)? -----------STORED STREAM lectures

I20150208-22:17:06.999(2)? SA lectures stored 54d7c44293006e8151f3758d

I20150208-22:17:06.999(2)? FS.File._saveChanges: lectures

I20150208-22:17:07.000(2)? UPDATE: {"$set":{"copies.lectures":{"name":"113187.jpg","type":"image/jpeg","size":50246,"key":"54d7c44293006e8151f3758d","updatedAt":"2015-02-08T20:17:06.994Z","createdAt":"2015-02-08T20:17:06.994Z"}}}

I20150208-22:17:07.000(2)? 113187.jpg was successfully saved to the lectures store. You are seeing this informational message because you enabled debugging and you have not defined any listeners for the "stored" event on the lectureFiles collection.

I20150208-22:17:07.000(2)? -----------CLOSE STREAM lectures

I20150208-22:17:07.000(2)? -----------CLOSE STREAM lectures

I20150208-22:17:07.003(2)? FileWorker ADDED - calling deleteChunks for qDGwcT2AKiofibSB8

I20150208-22:17:07.004(2)? ---SA REMOVE

I20150208-22:17:07.358(2)? [Function]

I20150208-22:17:07.359(2)? Updating lectureFile:

I20150208-22:17:14.994(2)? Inserting lectureFile:

I20150208-22:17:14.994(2)? [Function]

I20150208-22:17:15.498(2)? Inserting lectureFile:

I20150208-22:17:15.499(2)? [Function]

I20150208-22:17:15.617(2)? token: eyJhdXRoVG9rZW4iOiJ0NVJaSGQ3UElFdElHSEgyLWk5TGNFUWduVGY5Q3FTeXIyVm9YblExYU1jIn0=

I20150208-22:17:15.619(2)? HTTP PUT (update) handler received chunk:  0

I20150208-22:17:15.620(2)? GET FILERECORD: HmC24EZp6gYsJNa66

I20150208-22:17:15.622(2)? Inserting lectureFile:

I20150208-22:17:15.622(2)? [Function]

I20150208-22:17:15.625(2)? createWriteStream _tempstore, internal: true

I20150208-22:17:15.626(2)? createWriteStreamForFileKey _tempstore

I20150208-22:17:15.642(2)? SA GridFS - DONE!

I20150208-22:17:15.643(2)? -----------STORED STREAM _tempstore

I20150208-22:17:15.644(2)? -----------CLOSE STREAM _tempstore

I20150208-22:17:15.647(2)? TempStore progress: Received 1 of 1 chunks for 1253653939_1-29.jpg

I20150208-22:17:15.647(2)? UPDATE: {"$set":{"uploadedAt":"2015-02-08T20:17:15.646Z"},"$unset":{"chunkCount":1,"chunkSum":1,"chunkSize":1}}
I20150208-22:17:15.647(2)? 1253653939_1-29.jpg was successfully uploaded. You are seeing this informational message because you enabled debugging and you have not defined any listeners for the "uploaded" event on the lectureFiles collection.

I20150208-22:17:15.660(2)? FileWorker ADDED - calling saveCopy lectures for HmC24EZp6gYsJNa66

I20150208-22:17:15.660(2)? saving to store lectures

I20150208-22:17:15.660(2)? createWriteStream lectures, internal: false

I20150208-22:17:15.660(2)? createWriteStreamForFileKey lectures

I20150208-22:17:15.661(2)? FS.TempStore creating read stream for HmC24EZp6gYsJNa66

I20150208-22:17:15.669(2)? createReadStream _tempstore

I20150208-22:17:15.670(2)? createReadStreamForFileKey _tempstore

I20150208-22:17:15.684(2)? token: eyJhdXRoVG9rZW4iOiJ0NVJaSGQ3UElFdElHSEgyLWk5TGNFUWduVGY5Q3FTeXIyVm9YblExYU1jIn0=

I20150208-22:17:15.715(2)? SA GridFS - DONE!

I20150208-22:17:15.715(2)? -----------STORED STREAM lectures

I20150208-22:17:15.715(2)? -----------STORED STREAM lectures

I20150208-22:17:15.715(2)? SA lectures stored 54d7c44b93006e8151f37592

I20150208-22:17:15.715(2)? FS.File._saveChanges: lectures

I20150208-22:17:15.716(2)? UPDATE: {"$set":{"copies.lectures":{"name":"1253653939_1-29.jpg","type":"image/jpeg","size":77834,"key":"54d7c44b93006e8151f37592","updatedAt":"2015-02-08T20:17:15.704Z","createdAt":"2015-02-08T20:17:15.704Z"}}}

I20150208-22:17:15.716(2)? 1253653939_1-29.jpg was successfully saved to the lectures store. You are seeing this informational message because you enabled debugging and you have not defined any listeners for the "stored" event on the lectureFiles collection.

I20150208-22:17:15.717(2)? -----------CLOSE STREAM lectures

I20150208-22:17:15.717(2)? -----------CLOSE STREAM lectures

I20150208-22:17:15.722(2)? FileWorker ADDED - calling deleteChunks for HmC24EZp6gYsJNa66

I20150208-22:17:15.723(2)? ---SA REMOVE

I20150208-22:17:15.775(2)? token: eyJhdXRoVG9rZW4iOiJ0NVJaSGQ3UElFdElHSEgyLWk5TGNFUWduVGY5Q3FTeXIyVm9YblExYU1jIn0=

I20150208-22:17:15.841(2)? token: eyJhdXRoVG9rZW4iOiJ0NVJaSGQ3UElFdElHSEgyLWk5TGNFUWduVGY5Q3FTeXIyVm9YblExYU1jIn0=

I20150208-22:17:15.908(2)? token: eyJhdXRoVG9rZW4iOiJ0NVJaSGQ3UElFdElHSEgyLWk5TGNFUWduVGY5Q3FTeXIyVm9YblExYU1jIn0=

I20150208-22:17:15.971(2)? token: eyJhdXRoVG9rZW4iOiJ0NVJaSGQ3UElFdElHSEgyLWk5TGNFUWduVGY5Q3FTeXIyVm9YblExYU1jIn0=

I20150208-22:17:16.006(2)? [Function]

I20150208-22:17:16.006(2)? Updating lectureFile:

Collection is defined as follows:

var lectureStore = new FS.Store.GridFS("lectures");

LectureFiles = new FS.Collection("lectureFiles", {
    stores :[lectureStore],
    filter:{
    maxSize: 300 * 1024 * 1024,

    onInvalid: function (message) {
    if(Meteor.isClient){
        alert(message);
    }else{
        console.warn(message);
    }
    }
    }
});

//TODO: Improve security here
LectureFiles.allow({
    insert: function(userId, file) {
    console.log("Inserting lectureFile:");
    console.dir(file.name);
    check(arguments, [Match.Any]);
    return true;
},
update: function(userId, file, fields, modifier) {
    console.dir(file.name);
    console.log("Updating lectureFile:");
    check(arguments, [Match.Any]);
return true;
},
remove: function(userId, file) {
    check(arguments, [Match.Any]);
    return true;
},
download: function() {
    check(arguments, [Match.Any]);
    return true;
}
});

if(Meteor.isServer){
    Meteor.publish('images', function () {
    return Images.find();
   });

   Meteor.publish('lectureFiles', function () {
    return LectureFiles.find();
   });

}else{
   Meteor.subscribe('images');
   Meteor.subscribe('lectureFiles');
}

Please advise

rhyslbw commented 9 years ago

Still having a problem?

flamedmg commented 9 years ago

yes

rhyslbw commented 9 years ago

Might need to make a demo repository that just has the minimum to reproduce the error, excluding the drop event logic, as it seems to be a client side issue.

TuurDutoit commented 9 years ago

Has this been resolved? I get the same logs and after two days, I still didn't figure this out.