我对 BlobStore 非常陌生,我从客户端收到 Base64 图像 我这样转换它:
byte [] picByte = Base64.decodeBase64(pic);
Blob blob = new Blob(picByte);
我正在使用 jersey 2,我的目标是保存这张图片并稍后获取服务链接 blobstoreService.serve
如何保存这张带有 Jersey 2 的图像? 谢谢,
最佳答案
byte[] picByte = Base64.decodeBase64(pic);
GcsFileOptions instance = new GcsFileOptions.Builder().mimeType("image/jpeg").build();
GcsFilename fileName = new GcsFilename("xxx-app.appspot.com", "someName.jpg");
GcsOutputChannel outputChannel;
GcsService gcsService = GcsServiceFactory.createGcsService();
outputChannel = gcsService.createOrReplace(fileName, instance);
ByteBuffer a = ByteBuffer.wrap(picByte);
outputChannel.write(a);
outputChannel.close();
关于java - 如何将客户端发送的Base64图像存储在BlobStore中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42648721/