![](/img/trans.png)
[英]Fetching image from URL and uploading to another via POST in NodeJS
[英]Fetching a POST request in Meteor via a notification url
这是我没有经验的。
在我正在建立的管理页面上,可以将图片上传到称为Cloudinary的服务以删除其背景,此过程最多需要24小时,然后他们将POST请求发送到我随同发送的某些网址请求。
这种格式无法很好地进行实验,因此我需要一些帮助。
这是图片上传和发送请求的方式:
Cloudinary.upload(image, {
folder: "cutouts",
type: "upload",
notification_url: "someurl.com"
background_removal: "remove_the_background"
}, function(error, result) {
if (!error)
console.dir(result)
}
})
问题 :我应将什么设置为notification_url
? 即使它在我的网站上,我是否需要部署它才能检查代码是否有效?
根据他们的文档,这是他们将退回的款项的示例:
{
"notification_type": "info",
"info_kind": "remove_the_background",
"info_status": "complete",
"public_id": "wood_chair",
"uploaded_at": "2014-10-26T11:35:22Z",
"version": 1414316122,
"url":
"http://res.cloudinary.com/demo/image/upload/v1393688588/wood_chair.jpg",
"secure_url":
"https://res.cloudinary.com/demo/image/upload/v1393688588/wood_chair.jpg",
"etag": "a56e9e88c2add15cac1775c1f687bf73"
}
因此,特别是我需要访问info_status
和url
。
问题是,我无法做实验,而且我也不知道如何解决该问题,因为我完全没有经验。
如果有帮助,请参见以下文档: http : //cloudinary.com/documentation/remove_the_background_image_editing_addon
我该怎么做呢?
在服务器端,设置一条路由(假设您使用的是Iron-router)来处理cloudinary中的帖子:
Router.route('/api/cloudinary', { where: 'server' })
.post(function() {
var body = this.request.body; // get the body out of the response
var url = body.url; // based on the JSON you showed
this.response.statusCode = 200; // set the status code to be returned to cloudinary
this.response.end(); // send response
}
);
您可以将/api/cloudinary/
更改为所需的任何值。 如果您的网站是http://www.example.com
,则云端通知网址为:
http://www.example.com/api/cloudinary
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.