在我的ParseCloud-function
中,我想从网址中检索缩略图(JPG / PNG)并将其另存为ParseFile
。
ParseCloud功能
Parse.Cloud.define("statusDone",function(request,response)
{
Parse.Cloud.useMasterKey();
var doneObjectId = request.params.doneObject;
s_status = request.params.s_status;
s_message = request.params.s_message;
s_link = request.params.s_link;
var StatusObject = Parse.Object.extend("Status");
var sObject = StatusObject .createWithoutData( doneObjectId );
sObject .set("isDone", true);
sObject .set("link", s_link);
sObject .set("message", s_message);
sObject .set("statusColor", s_statusColor);
...
}
在此,我想获取link
的缩略图并将其另存为ParseFile
答案 0 :(得分:0)
你可以做的是在你的云代码中使用Parse.Cloud.httpRequest,从那里执行对s_link的调用,得到结果并将其保存在Parse.File这里是一些代码片段:
Parse.Cloud.httpRequest({
url: s_link,
headers: {
// in case you need request headers
}
}).then(function(res) {
// here you get the result from here you can create your Parse.File in the following way (from parse js DOCS).
// 1. create file with bytes
// var bytes = [ 0xBE, 0xEF, 0xCA, 0xFE ];
// var file = new Parse.File("file_name}", bytes,"{content_type}");
// 2. create with base64 string
// var base64 = "V29ya2luZyBhdCBQYXJzZSBpcyBncmVhdCE=";
// var file = new Parse.File("myfile.txt", { base64: base64 });
});