Я могу получить объект Blob из приведенного ниже кода в java. Мне нужно получить указанную c версию. Я попытался добавить # generation = 1242141424214 (abc / xyx / filename.json # generation = 1242141424214) в конце местоположения JSON, но получить Blob как ноль.
Может кто-нибудь помочь в этом? Спасибо!
//Get the Storage object
Storage storage =null;
try{
StorageOptions options = StorageOptions.newBuilder()
.setProjectId(PROJECT_ID)
.setCredentials(GoogleCredentials.fromStream(
new FileInputStream("serviceaccount.json"))).build();
storage = options.getService();
}catch (Exception e){
logger.error("Error creating storage object");
e.printStackTrace();
}
return storage;
//Get the Blob
try {
Blob blob = GCPStorage.getInstance().getGCPStorage().get(BUCKET_NAME, “**abc/xyx/filename.json**”);
if (blob != null) {
fileContent = new String(blob.getContent());
logger.debug("fileContent : " + fileContent);
}
logger.debug("End time : " + System.currentTimeMillis());
blob = null;
} catch (Exception e) {
logger.debug("Exception : " + e.getMessage());
e.printStackTrace();
throw new Exception("Failed reading the JSON :" + queryData.getObjectLocation());
}