【发布时间】:2015-05-29 14:23:55
【问题描述】:
如何在核心 java 的 couchbase lite 中保存图像? 当我们在 couchase 服务器中保存图像时,我们将图像转换为字节而不是保存字节。 但它在couchbase lite中没有这样的。 请帮助我。
final BufferedImage image = ImageIO.read(new File(file.getPath()));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "png", baos);
Document img_doc = db.getDocument("image");
Map<String, Object> img_properties = new HashMap<String, Object>();
img_properties.put("image", bytes);
img_doc.putProperties(img_properties);
【问题讨论】:
-
我将图像转换为字节数组并将其保存到 couchbase lite 文档 final BufferedImage image = ImageIO.read(new File(file.getPath())); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "png", baos);文档 img_doc = db.getDocument("image"); Map
img_properties = new HashMap (); img_properties.put(“图像”,字节); img_doc.putProperties(img_properties);
标签: java image save couchbase-lite