我是BlobStore的新手,我从客户端收到一个Base64图像 我正在转换它:
byte [] picByte = Base64.decodeBase64(pic);
Blob blob = new Blob(picByte);
我正在使用球衣2,我的目标是保存这张照片,然后获得服务链接blobstoreService.serve
如何使用平针织物2保存此图像? 谢谢,
答案 0 :(得分:0)
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();