【发布时间】:2014-10-31 02:30:37
【问题描述】:
我正在尝试将资产上传到 apigee baas,为此我遵循此处的文档: http://apigee.com/docs/api-baas/content/assets
这是我的代码:
var querystring = require('querystring');
var data = querystring.stringify({
filename: 'car_123.jpg', //asset's name on Apigee
file_location: 'http://cdn.xxxx.com/cars/123.jpg' //asset's original destination
});
var target_url = "https://api.usergrid.com/<org>/<app>/cars/<uuid>?access_token=dummyaccesstokenfor_SO"
var options = {
method: 'POST',
url: target_url,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
};
var request = require('request');
request(options, function(err, data) {
if (err) {
console.log(err)
} else {
console.log('success')
};
});
当我运行它时,我会收到一条成功消息。我想相信来自cdn的图像是物理的 复制到 Apigee 中。好像不是这样的
因为,当我发出 GET on https://api.usergrid.com/org/app/cars/uuid?access_token=dummyaccesstokenfor_SO 带有标题“Accept:image/jpeg”,我得到的只是这个
filename=cars_123.jpg&file_location='http://cdn.xxxx.com/cars/123.jpg
并且没有 base64 图像字符串或图像 url。
我哪里错了?
编辑:我在 BaaS GUI 中也看不到任何内容
EDIT2:根据 remus 的建议
curl -X POST -i -F name='apple-128' -F file=@"https://cdn4.iconfinder.com/data/icons/flat-brand-logo-2/512/apple-128.png" 'http://requestb.in/11xu3h61'
这导致
curl: (26) 无法打开文件“https://cdn4.iconfinder.com/data/icons/flat-brand-logo-2/512/apple-128.png”
这里使用的 cdn 只是一个占位符。但是我的cdn的结果是一样的。因此,它甚至在 POST 之前就失败了。让我想知道文件位置是否可以是 http 位置?
【问题讨论】:
标签: javascript node.js apigee