Downloaded file from collection
Opened this issue · 0 comments
iehdk commented
It eludes my how to download a file stored server side. Here I use HTTP.get, but the file content is a bunch of javascript text and not CSV data as expected. I suspect the problem is that I download the file immediately after uploading it, and that it is not completely stored. If I inspect the files on the server manually they are fine.
/* globals Meteor HTTP */
import { withTracker } from 'meteor/react-meteor-data';
import NavBar from '../../client/components/navbar.component';
import Files from '../../imports/api/files.collection';
const fileSubscription = () => {
const filesSub = Meteor.subscribe('allFiles');
return {
filesReady: filesSub.ready(),
fileUpload: (file, callback) => {
Files.insert(file, callback);
},
fileDownload: (url, callback) => {
HTTP.get(url, callback);
},
files: Files.find({}, {
sort: { uploadedAt: -1 }, // FIXME
}).fetch(),
};
};
export default NavBarContainer = withTracker(fileSubscription)(NavBar);