【发布时间】:2017-05-08 14:16:09
【问题描述】:
此代码将图像保存到谷歌云存储:
byte[] picByte = Base64.decodeBase64(pic);
GcsFileOptions instance = GcsFileOptions.getDefaultInstance();
GcsFilename fileName = new GcsFilename("xxx-app.appspot.com", "/gs/someName.jpg");
GcsOutputChannel outputChannel;
GcsService gcsService = GcsServiceFactory.createGcsService();
outputChannel = gcsService.createOrReplace(fileName, instance);
ByteBuffer a = ByteBuffer.wrap(picByte);
outputChannel.write(a);
outputChannel.close();
但这会在没有 image/jpeg 类型的情况下保存它。
如何以编程方式添加它,以便将图像直接保存为图像/jpeg?
任何帮助将不胜感激!
【问题讨论】:
标签: java google-app-engine google-cloud-storage