Meteor-Community-Packages/Meteor-CollectionFS

collectionFS

Imokeq opened this issue · 1 comments

Hello, everyone!

I encountered a problem when using collectionFS

The following error occurred after clicking the splicing url of the uploaded image in the browser console:

Error in method "/cfs/files/:value/:value/:value/", Error: TypeError: Cannot read property 'images-original' of undefined
at Object.httpGetHandler (packages/cfs_access-point.js:380:33)
at Object.get (packages/cfs_access-point.js:698:39)
at packages/cfs_http-methods.js:604:33

FS.debug Print log:
I20180605-14:11:58.356(8)token:eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0 =
I20180605-14:11:58.358(8)? HTTP PUT (update) handler received chunk: 0
I20180605-14:11:58.358(8)? GET FILERECORD: rWpYP6kzRrvfLJb7R
I20180605-14:11:59.060(8)? token: eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0=
I20180605-14:11:59.063(8)? HTTP PUT (update) handler received chunk: 0
I20180605-14:11:59.063(8)? GET FILERECORD: rWpYP6kzRrvfLJb7R
I20180605-14:11:59.431(8)? token: eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0=
I20180605-14:11:59.435(8)? HTTP PUT (update) handler received chunk: 0
I20180605-14:11:59.435(8)? GET FILERECORD: rWpYP6kzRrvfLJb7R
I20180605-14:11:59.496(8)? token: eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0=
I20180605-14:11:59.502(8)? HTTP PUT (update) handler received chunk: 0
I20180605-14:11:59.502(8)? GET FILERECORD: rWpYP6kzRrvfLJb7R
I20180605-14:12:00.202(8)? token: eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0=
I20180605-14:12:00.205(8)? HTTP PUT (update) handler received chunk: 0
I20180605-14:12:00.205(8)? GET FILERECORD: rWpYP6kzRrvfLJb7R
I20180605-15:46:12.822(8)? token: undefined
I20180605-15:46:12.827(8)? GET FILERECORD: rWpYP6kzRrvfLJb7R
I20180605-16:30:45.208(8)? images-original FileSystem mounted on: /usr/operater/testApp/uploads/pic
I20180605-16:30:45.287(8)? FS.HTTP.unmount:
I20180605-16:30:45.289(8)? {}
I20180605-16:30:45.289(8)? Registered HTTP method URLs:
I20180605-16:30:45.290(8)? /cfs/files/:collectionName/:id/:filename
I20180605-16:30:45.291(8)? /cfs/files/:collectionName/:id
I20180605-16:30:45.291(8)? /cfs/files/:collectionName
I20180605-16:30:45.296(8)Server up

It seems the upload is interrupted

incilent/main.js:

Template.mytemplate.events({
'change #uploadfile': function(event, template) {

idCardImgInsert();    
},
'click #idcards':function(event){
	console.log(Session.get('imgId'));
	return alert('##');
},  

})

function idCardImgInsert(){
var idCardImageUrl = '';
var idCardImg = new FS.File($('#uploadfile').get(0).files[0]);
console.log('idCardImg',idCardImg);
if(idCardImg){
var idCardImgObj = Images.insert(idCardImg,function(err,result){
if(err) console.log(err);

  console.log(result); 
    });             
    if(idCardImgObj.original.name){                                    
        idCardImageUrl ="http://103.231.255.47:8090/cfs/files/" 
        + idCardImgObj.collectionName 
        + "/" + idCardImgObj._id + "/" +idCardImgObj.original.name;
        idCardImageId = idCardImgObj._id;

    console.log(idCardImgObj);

    console.log(idCardImageUrl);
    idCardImgObj.url({brokenIsFine: true});            
        Session.set("imgId",idCardImgObj._id);
        console.log('imgId',idCardImgObj._id);
    }
}
var idCardUrl = {
    idCardImageUrl: idCardImageUrl,
}
return  idCardUrl; 

}

FS.HTTP.setBaseUrl('/cfs');

in lib/images.js:

FS.debug = true;
Images = new FS.Collection('Images', {
stores: [new FS.Store.FileSystem('images-original', {path: '/usr/operater/testApp/uploads/pic'})],
internal : true,
filter: {
maxSize: 204800, // in bytes
allow: {
contentTypes: ['image/*'],
extensions: ['png','jpg','jpeg','img'],
},
onInvalid: function (message) {
if (Meteor.isClient) {
alert(message);
} else {
console.log(message);
}
}
}
});

if (Meteor.isServer) {
Meteor.startup(function () {
console.log("Server up");
});
}

in server/server.js:

FS.debug = true;
Images.allow({
'insert': function(userId, party) {
return true;
},
'update': function(userId, party) {
return true;
},
'remove': function(userId, party) {
return true;
},
'download': function(userId, fileObj) {
return true;
},

});

Meteor.publish('Images', function(selector){
var userId = this.userId;
return Images.find(selector);
});

packags:
cfs:filesystem 0.1.2
cfs:standard-packages 0.5.10
cfs:tempstore 0.1.6
cfs:ui 0.1.3
ecmascript 0.10.9
es5-shim 4.7.3
insecure 1.0.7
jquery

meteor version:1.6.1
mongodb version:2.4.9

please help me!!!!

Emmmmm...This is the wrong version, updated more concise and easy to understand:#1034