我想将图像保存在字节数组中..并保存到 mongoDb 数据库中..并将字节数组取回图像文件并显示到 .GSP 页面
领域
class Profile{
static mapWith = "mongo"
String firstname
String lastname
byte[] imgpath
}
控制器
def saveimage{
File filepath = new File("C:\\man-of-steel-theme.jpg");
def encodedData = filepath.bytes;
profile.imgpath=encodedData;
profile.save();
}
在此不确定是否将正确的字节数组保存到 mongodb 并且无法获取图像文件