尝试在解析中使用 HTTP 请求获取图像属性时出错
Error when trying to get image properties using HTTP reuest in parse
我收到错误 141,说对象没有方法“成功”,使用以下代码。我只需要从 url 获取图像属性。附件是来自 Corona SDK 的完整错误。
Parse.Cloud.define("changePhoto4", function(request, response) {
var Image = require("parse-image");
var baseurl = "http://files.parsetfss.com/7bdfab67-db97-4761-936f-be05679ca518/tfss-dc75c8e2-06b6-45fb-bfde-b2befb8ad84a-0.png";
var params = {
}
return Parse.Cloud.httpRequest({
url: baseurl,
success: function(response) {
var image = new Image();
return image.setData(response.buffer, {
success: function() {
response.success("Image is " + image.width() + "x" + image.height() + ".");
},
error: function(error) {
response.error(image);
}
})
},
},
function (error) {
console.error('Console Log response: ' + error.text);
response.error('Request failed with response ' + error.text)
});
});
Parse.Cloud.define("changePhoto3", function(request, response) {
var baseurl = "http://farm4.static.flickr.com/3123/2341623661_7c99f48bbf_m.jpg";
var Image = require("parse-image");
var params = {
}
return Parse.Cloud.httpRequest({
method: 'POST',
url: baseurl,
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: params
}).then(function(httpResponse) {
var image = new Image();
return image.setData(httpResponse.buffer, {
success: function() {
console.log("Image is " + image.width() + "x" + image.height() + ".");
response.success(image.width()+"x" + image.height());
},
error: function(error) {
// The image data was invalid.
}
})
},
function (error) {
console.error('Console Log response: ' + error.text);
response.error('Request failed with response ' + error.text)
});
});
我收到错误 141,说对象没有方法“成功”,使用以下代码。我只需要从 url 获取图像属性。附件是来自 Corona SDK 的完整错误。
Parse.Cloud.define("changePhoto4", function(request, response) {
var Image = require("parse-image");
var baseurl = "http://files.parsetfss.com/7bdfab67-db97-4761-936f-be05679ca518/tfss-dc75c8e2-06b6-45fb-bfde-b2befb8ad84a-0.png";
var params = {
}
return Parse.Cloud.httpRequest({
url: baseurl,
success: function(response) {
var image = new Image();
return image.setData(response.buffer, {
success: function() {
response.success("Image is " + image.width() + "x" + image.height() + ".");
},
error: function(error) {
response.error(image);
}
})
},
},
function (error) {
console.error('Console Log response: ' + error.text);
response.error('Request failed with response ' + error.text)
});
});
Parse.Cloud.define("changePhoto3", function(request, response) {
var baseurl = "http://farm4.static.flickr.com/3123/2341623661_7c99f48bbf_m.jpg";
var Image = require("parse-image");
var params = {
}
return Parse.Cloud.httpRequest({
method: 'POST',
url: baseurl,
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: params
}).then(function(httpResponse) {
var image = new Image();
return image.setData(httpResponse.buffer, {
success: function() {
console.log("Image is " + image.width() + "x" + image.height() + ".");
response.success(image.width()+"x" + image.height());
},
error: function(error) {
// The image data was invalid.
}
})
},
function (error) {
console.error('Console Log response: ' + error.text);
response.error('Request failed with response ' + error.text)
});
});