У меня есть форма карьеры, где у меня есть все детали с вложенным файлом.Теперь я могу хранить файл.Я могу отправить электронное письмо, но отправка электронной почты с вложением не происходит, потому что у меня есть две модели: одна - для вложения, а другая - постоянная модель.В attachment.js я могу получить имя файла, но не могу отправить электронное письмо с вложением.Вот код.
career.js
'use strict';
const app = require('../../server/server');
module.exports = function(Career) {
Career.afterRemote('create', function(context, remoteMethodOutput, next) {
next();
console.log(context.result) //here i dont have the file name
Career.app.models.Email.send({
to: 'lakshmipriya.l@gmail.com',
from: 'lakshmi@gmail.com',
subject: 'my Career Form',
html: 'my message'
}, function(err, mail) {
// console.log(context.result.email)
console.log('email sent!');
cb(err);
});
});
};
career.json
{
"name": "career",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"id": {
"type": "number"
},
"firstname": {
"type": "string",
"required": true
},
"email": {
"type": "string",
"required": true
},
"message": {
"type": "string",
"required": true
},
"resume": {
"type": "string"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
приложение.js
'use strict';
module.exports = function(Attachment) {
Attachment.afterRemote('upload',function(ctx, modelInstance, next){
console.log('create file',modelInstance.result.files.file);
next();
});
};
Здесь, если я применяю оба кода, я получаю ошибку.Как извлечь имя файла из одной модели в другую и отправить электронное письмо?