[英]How to store Base64 image sent from client in BlobStore
我是BlobStore的新手,我从客户端收到一个Base64图像我正在转换它像这样:
byte [] picByte = Base64.decodeBase64(pic);
Blob blob = new Blob(picByte);
我正在使用球衣2,我的目标是保存这张图片,然后获得服务链接blobstoreService.serve
如何用球衣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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.