Warum zeigt es in meiner Vorlage keinen Dateieintrag an? Die einzige Sache, die es zu der Schablone zurückbringt, ist nur das "Cursor" -Objekt.Meteor.js - Zeigt keine Abonnementdaten an, nur das Cursorobjekt
Was die console.log (Datei) Ausgabe in der JS-Konsole ist:
FilesCollection {collectionName: "Files", downloadRoute: "/cdn/storage", schema: Object, chunkSize: 524288, namingFunction: false…}
Ich habe bei jedem Post sieht, etc. Ich weiß es, einen Cursor an den Client zurück, aber ich bin macht eine Files.findOne() - Abfrage, die den Datensatz selbst an die Vorlage/html zurückgeben soll.
'/imports/api/files.js'
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
export const Files = new FilesCollection({
collectionName: 'Files',
allowClientCode: false, // Disallow remove files from Client
onBeforeUpload: function (file) {
// Allow upload files under 10MB, and only in png/jpg/jpeg formats
if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
return true;
} else {
return 'Please upload image, with size equal or less than 10MB';
}
}
});
if (Meteor.isServer) {
// This code only runs on the server
Meteor.publish('getFile', function(id) {
return Files.find({_id: id }).cursor;
});
}
'/imports/ui/components/download.js'
import './download.html';
import { Files } from '../../api/files.js';
Template.download.onCreated(function() {
let self = this;
self.autorun(function() {
let fileId = FlowRouter.getParam('id');
self.subscribe('getFile', fileId);
});
});
Template.download.helpers({
file: function() {
let fileId = FlowRouter.getParam('id');
let file = Files.findOne({_id: fileId}) || {};
console.log(file)
return file;
}
});
‚/ Einfuhr/ui/components/download. html '