Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor-Meteor CollectionFS-截取文件,以便通过电子邮件发送并保存_Meteor_Base64_Pdf Generation_Mandrill_Collectionfs - Fatal编程技术网

Meteor-Meteor CollectionFS-截取文件,以便通过电子邮件发送并保存

Meteor-Meteor CollectionFS-截取文件,以便通过电子邮件发送并保存,meteor,base64,pdf-generation,mandrill,collectionfs,Meteor,Base64,Pdf Generation,Mandrill,Collectionfs,我正在使用Meteor CollectionFS上传pdf文件。它使用S3存储它,这一切都正常工作。我的问题涉及如何截取文件并将其转换为base64String,以便使用Mandrill将此pdf的副本通过电子邮件发送给用户,并将其存储以备将来使用 以下是我目前掌握的代码: Template.dropzone.events({ 'dropped #dropzone': function(e) { FS.Utility.eachFile(e, function(file)

我正在使用Meteor CollectionFS上传pdf文件。它使用S3存储它,这一切都正常工作。我的问题涉及如何截取文件并将其转换为base64String,以便使用Mandrill将此pdf的副本通过电子邮件发送给用户,并将其存储以备将来使用

以下是我目前掌握的代码:

    Template.dropzone.events({
  'dropped #dropzone': function(e) {
      FS.Utility.eachFile(e, function(file) {

                Meteor.call('testEmailUpload', file.toString('base64'));

        var newFile = new FS.File(file);
        Images.insert(newFile, function (error, fileObj) {
          if (error) {
            toastr.error("Upload failed... please try again.");
          } else {
            toastr.success('Upload succeeded!');
          }
      });
    });
  }
});
用于发送电子邮件的方法调用

'testEmailUpload': function (base64String){
        Mandrill.messages.send({
                message: {
                        subject: 'Test Email',
                        from_email: "xxxxxxxx",
                        from_name: "xxxxxxxx",
                        to: [{ email: "xxxxxxxx"}],
                        text: "TestEmail Upload Files",
                        headers: {"Reply-To": "xxxxxxxx"    },
                        attachments: [{
                                type: "application/pdf",
                                name: "TestPDF.pdf",
                                content: base64String
                        }]
                }
        },
        function(result) {
        }, function(e) {
                // Mandrill returns the error as an object with name and message keys
                console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message);
                // A mandrill error occurred: Unknown_Subaccount - No subaccount exists with the id 'customer-123'
        });
    }
这适用于上传,没有问题。但是,我不知道应该调用什么来获取要传递到该方法的实际base64string。电子邮件现在正在发送,但是pdf从未正确创建

非常感谢您的帮助