【问题标题】:How to store Base64 image sent from client in BlobStore如何在 BlobStore 中存储从客户端发送的 Base64 图像
【发布时间】:2017-07-27 16:28:05
【问题描述】:

我对 BlobStore 非常陌生,我收到了来自客户端的 Base64 图像 我是这样转换的:

byte [] picByte = Base64.decodeBase64(pic);
Blob blob = new Blob(picByte);

我正在使用球衣 2,我的目标是保存这张图片,然后获取服务链接blobstoreService.serve

如何使用球衣 2 保存此图像? 谢谢,

【问题讨论】:

    标签: java google-app-engine jersey blob blobstore


    【解决方案1】:
        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();
    

    【讨论】:

      猜你喜欢
      • 2016-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-11
      • 2014-04-05
      • 2017-06-25
      • 2016-11-27
      相关资源
      最近更新 更多