I need to save an image file in the column Adjunto
, I do not know
我需要在Adjunto列中保存图像文件,我不知道
var comentario = new CB.CloudObject('Comentarios');
comentario.set("IdPersona", new CB.CloudObject("User", "4bD5Gz7Q"));
comentario.set("IdEmpresa", new CB.CloudObject("User", id));
comentario.set("Comentario", coment);
comentario.set("Calificacion", parseInt(calificacion));
comentario.set("Ubicacion", new CB.CloudGeoPoint(gps[0],gps[1]));
comentario.set("Adjunto",function(){
new CB.CloudFile(foto).set('name',"foto.jpg").save({
success : function(cloudFile){
alert(cloudFile.URL);
}, error: function(error){
alert("error: "+error);
}
});
});
comentario.save({
success: function(data){
alert("Exito!");
}, error: function(error){
alert("Error: "+error);
}
});
}
The param foto is an object $cordovaCapture.captureImage
named imageData[0]
.
param foto是一个名为imageData [0]的对象$ cordovaCapture.captureImage。
1 个解决方案
#1
0
You cannot set a function() to a column. That's not valid.
您不能将函数()设置为列。那是无效的。
Try this instead :
试试这个:
var fileUploadControl = $("#profilePhotoFileUpload")[0];
if (fileUploadControl.files.length > 0) {
var file = fileUploadControl.files[0];
var name = "photo.jpg";
var cloudFile = new CB.CloudFile(file);
cloudFile.set('name', name);
cloudFile.save({
success: function(cloudFile) {
//You can now use this cloudFile object to save it in your CloudObject.
comentario.set("IdPersona", new CB.CloudObject("User", "4bD5Gz7Q"));
comentario.set("IdEmpresa", new CB.CloudObject("User", id));
comentario.set("Comentario", coment);
comentario.set("Calificacion", parseInt(calificacion));
comentario.set("Ubicacion", new CB.CloudGeoPoint(gps[0], gps[1]));
comentario.set("Adjunto", cloudFile);
comentario.save({
success: function(data) {
alert("Exito!");
},
error: function(error) {
alert("Error: " + error);
}
});
},
error: function(error) {
//error
}
})
}
#1
0
You cannot set a function() to a column. That's not valid.
您不能将函数()设置为列。那是无效的。
Try this instead :
试试这个:
var fileUploadControl = $("#profilePhotoFileUpload")[0];
if (fileUploadControl.files.length > 0) {
var file = fileUploadControl.files[0];
var name = "photo.jpg";
var cloudFile = new CB.CloudFile(file);
cloudFile.set('name', name);
cloudFile.save({
success: function(cloudFile) {
//You can now use this cloudFile object to save it in your CloudObject.
comentario.set("IdPersona", new CB.CloudObject("User", "4bD5Gz7Q"));
comentario.set("IdEmpresa", new CB.CloudObject("User", id));
comentario.set("Comentario", coment);
comentario.set("Calificacion", parseInt(calificacion));
comentario.set("Ubicacion", new CB.CloudGeoPoint(gps[0], gps[1]));
comentario.set("Adjunto", cloudFile);
comentario.save({
success: function(data) {
alert("Exito!");
},
error: function(error) {
alert("Error: " + error);
}
});
},
error: function(error) {
//error
}
})
}