У меня есть элемент с именем style, который имеет 2 атрибута: один с необработанным текстом css, а другой с S3Файл.
Style.add({
...
css: { type: Types.Code, language: 'css' },
cssFile: {
type: Types.S3File,
s3path: 'uploads/assets',
},
...
});
Я хочу обновить S3File, указав содержимое текста css.
function uploadCSStoAmazon(style) {
// Store css code in temporal file (with a md5 name)
var rndm = crypto.randomBytes(20).toString('hex'), file_path = '/tmp/css_temp_' + rndm + '.css';
fs.writeFile(file_path, style.css, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
// style.cssFile = new Types.S3File();
// TODO upload file to amazon
style.cssFile._.uploadFile(file_path, true, function(err, fileData){
// TODO erase css file
});
});
}
...
var aStyle = new Style.model({
...
css: 'Some css string',
...
});
...
uploadCSStoAmazon(aStyle);
Атрибут cssFile не определен, я так понимаю, но как мне создать новый файл и присвоить его этому атрибуту, а также загрузить файл?
uploadCSStoAmazon()
? - person JME   schedule 29.05.2015