我正在使用钛工作室,我正在尝试从 POST 请求中保存图像。
function buyImage(s){
var userName = Ti.App.Properties.getString('username');
var email = Ti.App.Properties.getString('email');
var encKey = Ti.App.Properties.getString('key');
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
onload : function(e) {
Ti.API.info("Key Text: " + this.responseData);
Titanium.Media.saveToPhotoGallery(this.responseData,{
success: function(e) {
Titanium.UI.createAlertDialog({
title:'Photo Gallery',
message:'Check your photo gallery for you image'
}).show();
},
error: function(e) {
Titanium.UI.createAlertDialog({
title:'Error saving',
message:e.error
}).show();
}
});
Titanium.UI.createAlertDialog({title:'Photo Gallery',message:'Photo saved to gallery'}).show();
},
onerror : function(e) {
Ti.API.info(e.error);
alert('error');
},
timeout : 5000 // in milliseconds
});
// Prepare the connection.
client.open("POST", "http://somesite/create/save?userName="+userName+"&encryptionKey="+encKey+"&email="+email+"&recordId="+s);
// Send the request.
client.send();
图像说它可以保存,它说响应数据是 TiBlob,但图像似乎根本没有保存。当在浏览器的发布事件中完成相同的发布时,系统会提示您下载图像。
有任何想法吗?