Skip to content

Commit 4eb3210

Browse files
committed
use Mongo.Collection.get if it exists to retrieve the fs collection, otherwise fallback to the former method
1 parent 8d7d785 commit 4eb3210

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lib/client/fileUpload.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ Template.afFileUpload.onCreated(function () {
1111
atts: {}
1212
};
1313
}
14-
15-
this.collection = Mongo.Collection.get(his.data.atts.collection); //Meteor.connection._mongo_livedata_collections[this.data.atts.collection];
14+
console.log(this.data);
15+
this.collection = Mongo.Collection.get
16+
? Mongo.Collection.get(this.data.atts.collection)
17+
: Meteor.connection._mongo_livedata_collections[this.data.atts.collection];
1618
this.uploadTemplate = this.data.atts.uploadTemplate || null;
1719
this.previewTemplate = this.data.atts.previewTemplate || null;
1820

@@ -45,7 +47,11 @@ Template.afFileUpload.helpers({
4547
return Template.instance().fileId.get() || this.value;
4648
},
4749
uploadedFile() {
48-
return global[Template.instance().collectionName()].findOne({
50+
var collectionName = Template.instance().collectionName();
51+
var collection = Mongo.Collection.get
52+
? Mongo.Collection.get(collectionName)
53+
: global[collectionName];
54+
return collection.findOne({
4955
_id: Template.instance().fileId.get() || this.value
5056
});
5157
}
@@ -69,7 +75,11 @@ Template.afFileUpload.events({
6975
},
7076
'change [data-files-collection-upload]'(e, template) {
7177
if (e.currentTarget.files && e.currentTarget.files[0]) {
72-
var upload = global[template.collectionName()].insert({
78+
var collectionName = template.collectionName();
79+
var collection = Mongo.Collection.get
80+
? Mongo.Collection.get(collectionName)
81+
: global[template.collectionName()];
82+
var upload = collection.insert({
7383
file: e.currentTarget.files[0],
7484
streams: 'dynamic',
7585
chunkSize: 'dynamic'

0 commit comments

Comments
 (0)