I’m using meteor uploads to handle some file uploads.
I want to get the _id of the current page. /uploads/:_id inside of a blaze template. Can flowrouter do this? Or how do I handle this? _id is undefined
UploaderJSX = React.createClass({
componentDidMount() {
// Use Meteor Blaze to render login buttons
this.view = Blaze.render(Template.uploader,
React.findDOMNode(this.refs.container));
},
componentWillUnmount() {
// Clean up Blaze view
Blaze.remove(this.view);
},
render() {
// Just render a placeholder container that will be filled in
return <span ref="container" />;
}
});
Template.uploader.helpers({
FormData: function() {
return {
_id: this._id,
userId: Meteor.userId(),
username: Meteor.user().username
}
}
});
Meteor.startup(function () {
UploadServer.init({
tmpDir: process.env.PWD + '/upload/tmp',
uploadDir: process.env.PWD + '/upload/',
uploadUrl: '/upload/',
checkCreateDirectories: true,
getDirectory: function(fileInfo, formData) {
// create a sub-directory in the uploadDir based on the content type (e.g. 'images')
return formData.username + '/' +formData.contentType;
},
finished: function(fileInfo, formFields, formData) {
// perform a disk operation
console.log(formFields);
let name = fileInfo.name
console.log(name);
let url = fileInfo.url;
let userId = formFields.userId
console.log(userId)
let _id = formFields._id
console.log(_id)
console.log(url);
Purchases.update(_id, {
$set: {path: {name: name, url: url}}
});
},