안녕하세요 저는 Meteor에서 새로 왔으며 간단한 파일/이미지 업로드/다운로드를 개발하려고합니다.Meteor 이미지를 업로드 할 수 없습니다.
내 코드와 패키지 :
meteor create testApp
meteor add cfs:standard-packages
meteor add cfs:filesystem
testApp.js :
YourFileCollection = new FS.Collection("yourFileCollection", {
stores: [new FS.Store.FileSystem("yourFileCollection", {path: "~/meteor_uploads"})]
});
if (Meteor.isClient) {
// counter starts at 0
Template.yourTemplate.events({
'change .your-upload-class': function(event, template) {
FS.Utility.eachFile(event, function(file) {
var yourFile = new FS.File(file);
yourFile.creatorId = Meteor.userId(); // add custom data
YourFileCollection.insert(yourFile, function (err, fileObj) {
if (!err) {
// do callback stuff
}
});
});
}
});
}
if (Meteor.isServer) {
YourFileCollection.allow({
insert: function (userId, doc) {
return !!userId;
},
update: function (userId, doc) {
return doc.creatorId == userId
},
download: function (userId, doc) {
return doc.creatorId == userId
}
});
}
및 HTML :
<head>
<title>protoSonn</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> yourTemplate}}
</body>
<template name="yourTemplate">
<input class="your-upload-class" type="file">
</template>
내/TestApp가/공용 폴더에도 두 이미지를 . 내 공용 폴더에서 이미지를 선택한 후 확인을 클릭하십시오. 아무것도 일어나지 않는다. mongodb에서 생성 된 콜렉션이 없습니다. 뭐가 문제 야?