When creating a blog on meteor js, I had a question, how best to organize adding images to a post?

To upload images to the server, I used the package: "ostrio: files", which uploads files along the path ".meteor / local / build / programs / server / assets / app / uploads / Images /". After downloading the image, I get the url of the image and upload it to the database with posts.

//добавление статьи Template.addPost.events({ 'submit form': function(e) { e.preventDefault(); var post = { titlename: $(e.target).find('[name=titlename]').val(), posttext: $(e.target).find('[name=posttext]').val(), categore: $('#categores').val(), //получение url картинки image: imagesURL }; Meteor.call('postInsert',post,function(err, result){ if (err) { throwError(error.reason); } Router.go('postPage', {_id: result._id}); }); }, 'change #fileInput': function (e, template) { if (e.currentTarget.files && e.currentTarget.files[0]) { file = e.currentTarget.files[0]; if (file) { var uploadInstance = Images.insert({ file: file, streams: 'dynamic', chunkSize: 'dynamic' }, false); uploadInstance.on('start', function() { template.currentUpload.set(this); }); uploadInstance.on('end', function(error, fileObj) { if (error) { alert('Загрузка не удалась: ' + error.reason); } else { //сохранение ссылки imagesURL = '.meteor/local/build/programs/server/assets/app/uploads/Images/' + fileObj._id+ '.png'; console.log(imagesURL); alert('Файл ' + fileObj.name + ' загружен!'); return imagesURL; } template.currentUpload.set(false); }); uploadInstance.start(); } } } }); 

However, using the resulting url as a link img tag does not give results. The image of the broken picture is displayed on the screen.

enter image description here

Image Insert Code

  <img src="{{image}}" alt="{{image}}"> 

As far as I understand, by default the meteor searches for all media files in the public folder. This may be my problem. Using relative links like:

".meteor / local / build / programs / server / assets / app / uploads / Images /" or "~ / .meteor / local / build / programs / server / assets / app / uploads / Images /"

No results were given.

Perhaps someone has already encountered a similar problem or used alternative ways to add images to posts.

I would be grateful for any help.

    1 answer 1

    The problem is solved, you need to take pictures by reference: http: // localhost: 3000 / cdn / storage / Images / Image Name / original / Image Name