我試圖將資產上傳到apigee巴斯對此我跟隨實況在這裏: 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。似乎這不是真的
因爲,當我在 https://api.usergrid.com/org/app/cars/uuid?access_token=dummyaccesstokenfor_SO與頭部發出GET '接受:圖像/ JPEG',我得到的是這樣的
名= cars_123.jpg & file_location =」 http://cdn.xxxx.com/cars/123.jpg
並且沒有base64圖片字符串或圖片url。
我哪裏錯了?
編輯:我沒有看到任何在巴斯GUI或者
EDIT2:按照萊姆斯的建議
捲曲-X POST -i -F名= '蘋果128' -F文件= @ 「https://cdn4.iconfinder.com/data/icons/flat-brand-logo-2/512/apple-128.png」 'http://requestb.in/11xu3h61'
這導致
捲曲: (26)無法打開文件「https://cdn4.iconfinder.com/data/icons/flat-brand-logo-2/512/apple-128.png」
此處使用的cdn只是一個佔位符。但是,我的cdn的結果是一樣的。所以,即使在POST之前,它也是失敗的。讓我懷疑文件位置是否可以成爲http位置?
我想GET URL是由SO格式化的。它確實按照您的建議閱讀相同的術語。 而我在BaaS GUI中沒有看到任何東西 – lonelymo 2014-09-06 10:38:07
嗯,有沒有一個實體?或者這個集合是空的? – brandonscript 2014-09-06 10:38:43
有。收集CARS充滿了汽車實體。現在我試圖給他們添加圖像 – lonelymo 2014-09-06 10:39:38