在Meteor方法中获取图像url

在Meteor方法中获取图像url,meteor,angular-meteor,collectionfs,Meteor,Angular Meteor,Collectionfs,我似乎找不到任何文档来解释如何将上传的collectionFS图像的文件名和文件路径输入meteor方法 我可以使用助手在客户端获取图像URL,但我似乎不知道如何将附加图像的文件名和文件路径发送到我的方法 方法JS Meteor.methods({ addQuote: function(data) { check(data, Object); var attachments = []; var html = html; // need to get the filename

我似乎找不到任何文档来解释如何将上传的collectionFS图像的
文件名
文件路径
输入meteor方法

我可以使用
助手在客户端获取图像URL,但我似乎不知道如何将附加图像的文件名和文件路径发送到我的方法

方法JS

Meteor.methods({
addQuote: function(data) {
  check(data, Object);

  var attachments = [];
  var html = html;

  // need to get the filename and filepath from collectionFS
  // I would then have the data go here
  attachments.push({filename: , filePath: }); 

  this.unblock();

  var email = {
    from:    data.contactEmail,
    to:      Meteor.settings.contactForm.emailTo,
    subject: Meteor.settings.contactForm.quoteSubject,
    html:    html,
    attachmentOptions: attachments
  };

  EmailAtt.send(email);
}
});
        function ($scope, $reactive, $meteor) {
          $reactive(this).attach($scope);

          this.user = {};


          this.helpers({
            images: () => {
              return Images.find({});
            }
          });

          this.subscribe('images');

          this.addNewSubscriber = function() {


            // Uploads the Image to Collection
            if(File.length > 0) {
              Images.insert(this.user.contactAttachment);
              console.log(this.user.contactAttachment);
            }

            // This is the variable I use to push to my method
            // I image I need to push the filename and filepath also
            // I am unsure how to access that information in the controller.
            var data = ({
              contactEmail: this.user.contactEmail,
              contactName: this.user.contactName,
              contactPhone: this.user.contactPhone,
              contactMessage: this.user.contactMessage
            });

            // This will push the data to my meteor method "addQuote"
            $meteor.call('addQuote', data).then(
              function(data){
              // Show Success
              },
              function(err) {
              // Show Error
              }
            );
          };
控制器JS

Meteor.methods({
addQuote: function(data) {
  check(data, Object);

  var attachments = [];
  var html = html;

  // need to get the filename and filepath from collectionFS
  // I would then have the data go here
  attachments.push({filename: , filePath: }); 

  this.unblock();

  var email = {
    from:    data.contactEmail,
    to:      Meteor.settings.contactForm.emailTo,
    subject: Meteor.settings.contactForm.quoteSubject,
    html:    html,
    attachmentOptions: attachments
  };

  EmailAtt.send(email);
}
});
        function ($scope, $reactive, $meteor) {
          $reactive(this).attach($scope);

          this.user = {};


          this.helpers({
            images: () => {
              return Images.find({});
            }
          });

          this.subscribe('images');

          this.addNewSubscriber = function() {


            // Uploads the Image to Collection
            if(File.length > 0) {
              Images.insert(this.user.contactAttachment);
              console.log(this.user.contactAttachment);
            }

            // This is the variable I use to push to my method
            // I image I need to push the filename and filepath also
            // I am unsure how to access that information in the controller.
            var data = ({
              contactEmail: this.user.contactEmail,
              contactName: this.user.contactName,
              contactPhone: this.user.contactPhone,
              contactMessage: this.user.contactMessage
            });

            // This will push the data to my meteor method "addQuote"
            $meteor.call('addQuote', data).then(
              function(data){
              // Show Success
              },
              function(err) {
              // Show Error
              }
            );
          };

您可以使用插入回调来获取以下信息:

Images.insert(fsFile, function (error, fileObj) 
{
      if (error) console.log(error);
      else 
      {
            console.log(fileObj);
             //Use fileObj.url({brokenIsFine: true}); to get the url
      }                           
});