Hi not sure what I'm doing wrong.
I create three different FilesCollectionsone for images, for videos and audio.
Upload is working great, but when I return results from the database, I'm getting a normal cursor instead of the FileCursor (or FilesCursor) and the important functions like link are not available...
I'm using the latest version of the Meteor and latest version of Meteor-Files as well (1.9.8).
The Pub:
Meteor.publish('myImages', function (albumId) {
if (this.userId) {
return Images.find({userId: this.userId, album: albumId}).cursor;
} else {
return this.ready();
}
});
The Sub:
Meteor.subscribe('myImages', this.currentAlbum());
The Query:
getAlbumImages: function () {
return Images.find({userId: Meteor.userId(), album: this.currentAlbum()}).cursor;
},
In the display, the link function returns undefined, I am currently constructing the path like this:
getLink: (image) => {
return `${image._downloadRoute}/${image._collectionName}/${image._id}/original/${image._id}.${image.ext}`;
}
But that's surely not how it should be...
I tried with a normal
{{#each getAlbumImages}}
<img src="{{this.link}}">
{{/each}}
and also
{{#each getAlbumImages.each}}
<img src="{{this.link}}">
{{/each}}
but the first one returns undefined on the link, the second one doesn't render anything.
Hello @JanSchuermannPH ,
I suggest to use this code in a "publish":
Meteor.publish('myImages', function (albumId) {
if (this.userId) {
return Images.collection.find({userId: this.userId, album: albumId});
} else {
return this.ready();
}
});
And your issue is in using .cursor at client side (where you get this from? If it is in the docs, it's a typo and should be removed), use this code instead:
getAlbumImages: function () {
return Images.find({userId: Meteor.userId(), album: this.currentAlbum()});
},
and in a Blaze:
{{#each getAlbumImages.each}}
<img src="{{link}}">
{{/each}}
let me know if this was helpful.
That was helpful, and I can now see the .link()actually returning something.
The next problem I'm having is that I implemented the image processing for thumbnail generation (thanks for the code btw, works like a charm!) and I can see the physical file and the versions entry in the database.
If I try and access the thumbnail though with .link('thumbnail') as described in the docs, it's returning a wrong file path. Instead of cdn/storage/images/abcdef/thumbnail-abcdef.jpg it's returning cdn/storage/images/abcdef/thumbnail/abcdef.jpg
I'm assuming I didn't get it again haha, but would you mind pointing me in the right direction a second time?
It might also be that thumbnail as a path is picked up by the library to server the correct version? Anyway, it's not showing up, the original is working fine.
EDIT
Nevermind, I had an issue in my code that prevented the images from loading.
All questions solved, thanks a lot for the support!
@JanSchuermannPH I'm glad your issues are solved. 馃帀
Please, support this project by: