유성과 collectionfs를 사용하는 프로젝트에서 작업하고 있습니다.collectionfs는 다운로드 URL을 생성합니다.
파일을 collectionfs에 업로드하고 파일 핸들러를 제자리에 두었습니다. {{cfsFileUrl "defaultFilehandler"}}
핸들러 도우미를 사용하면 이미지가 저장되는 URL을 표시 할 수 있지만이 URL에서 이미지를 다운로드 할 수는 없습니다. 나는 두 가지를 달성하고자하는 궁극적
: (3000 내가 로컬 호스트를 writen 것처럼) : 유성 페이지
localhost:3000/cfs/contacts/Nj3WzrBKhqd9Mc9NP_defaultHandler.png
유성 경로 나이 : 내 브라우저에 복사
1
표시하는 HTML 태그를 사용하여 이미지 :
0123을두 번째 사용자가이 이미지를 볼 수 있도록 허용하고 싶습니다.
'download-url'을 사용하면 보안 성이 충분하지 않습니다.
클라이언트 JS
ContactsFS = new CollectionFS('contacts', { autopublish: false });
Deps.autorun(function() {
Meteor.subscribe('myContactsFiles');
});
Template.queueControl.events({
'change .fileUploader': function (e) {
var files = e.target.files;
for (var i = 0, f; f = files[i]; i++) {
ContactsFS.storeFile(f);
}
}
});
서버 JS
ContactsFS = new CollectionFS('contacts', { autopublish: false });
ContactsFS.allow({
insert: function(userId, file) {
console.log('user'+userId+"file"+JSON.stringify(file));
console.log("WILL SAVE:"+userId && file.owner === userId);
return userId && file.owner === userId;
},
update: function(userId, files, fields, modifier) {
return _.all(files, function (file) {
return (userId == file.owner);
}); //EO iterate through files
},
remove: function(userId, files) { return false; }
});
Meteor.publish('myContactsFiles', function() {
if (this.userId) {
return ContactsFS.find({ owner: this.userId }, { limit: 30 });
}
});
ContactsFS.fileHandlers({
default1: function(options) { // Options contains blob and fileRecord — same is expected in return if should be saved on filesytem, can be modified
return { blob: options.blob, fileRecord: options.fileRecord }; // if no blob then save result in fileHandle (added createdAt)
}});
안녕하세요, 이미지를 표시 할 때 문제가 발생했습니다. "이미지로 해석되었지만 MIME 유형이 text/html로 전송 된 리소스 :"오류로 인해 깨진 이미지 아이콘이 나타납니다. 같은 문제에 직면 했습니까? – Junhao