我正在尝试创建一个Parse云代码函数,该函数将运行查询,然后将查询结果放在csv文件中,最后使用mailgun插件将其发送给收件人。
不幸的是,我无法弄清楚如何在云代码中创建Parse文件。建议?
Parse.cloud.define("exportDataViaEmail", function(request, response){
var query = new Parse.Query("Diaper");
var today = new Date();
var startTime = new Date(today - 1000 * 60 * 60 * 24 * (7*52+1));
query.lessThan("logCreationDate", today);
query.greaterThan("logCreationDate", startTime);
query.find({
success: {
//TODO I want store this in a Parse File but how?
},
error :{
}
});
})
/*
* Send email via mailgun
*/
Parse.Cloud.define("sendEmail", function(request, response){
Mailgun.sendEmail({
to: "myemail@gmail.com",
from: "hello@example.com",
subject: "Hello From example App",
text: "Using Parse and Mailgun is great!"
}, {
success: function(httpResponse) {
console.log(httpResponse);
response.success("Email sent!");
},
error: function(httpResponse) {
console.error(httpResponse);
response.error("Uh oh, something went wrong");
}
});
})
答案 0 :(得分:0)
使用云代码中的文件很简单,并在Parse Javascript Guide
中详细记录它就像var file = new Parse.File("myfile.txt", bytes);