public static BlobKey uploadFile(
String companyCode,
String fileName, String mimetype, byte[] data)
throws IOException {
//FileAPIが廃止となり、GCSを使う 2015/09/03
String bucketName = "locguide";
String objectName = companyCode + "_" + randomNumAllString(32);
GcsService gcsService = null;
GcsFilename gcsFilename = null;
GcsFileOptions options = null;
GcsOutputChannel writeChannel = null;
gcsService = GcsServiceFactory.createGcsService();
gcsFilename = new GcsFilename(bucketName, objectName);
String a = mimetype;
try {
options = new GcsFileOptions.Builder() ← コンパイルエラー???
.acl("private") .mimeType(mimetype)
.build();
writeChannel = gcsService.createOrReplace(gcsFilename, options);
writeChannel.write(ByteBuffer.wrap(data));
} catch (IOException exception) {
outputErrorLog(exception);
} finally {
try {
writeChannel.close();
} catch( IOException e) {
outputErrorLog(e);
}
}
// BlobKeyを作成
//AwohatoLog.outputLog("/gs/" + bucketName + "/" + objectName);
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = blobstoreService.createGsBlobKey("/gs/" + bucketName + "/" + objectName);
return blobKey;
}