[英]How to set TTL on a Blob in Google Cloud Storage using Java?
[英]INVALID_BLOB_KEY on retrieving image from Google Cloud storage using java
我正在嘗試使用Google Cloud存儲來存儲我將在jsp文件中使用的圖像。 我已經創建了存儲桶,上傳了一個圖像(用於測試目的),並嘗試從java類中檢索一個Url。 我一直收到錯誤消息
HTTP ERROR 500
Problem accessing /. Reason:
INVALID_BLOB_KEY: Could not read blob.
Caused by:
java.lang.IllegalArgumentException: INVALID_BLOB_KEY: Could not read blob.
at
com.google.appengine.api.images.ImagesServiceImpl.getServingUrl(ImagesServiceImpl.java:282)
我創建的Bucket
我用來檢索Url的代碼(BUCKETNAME是一個帶有桶名稱的靜態字符串)
public static String getImageURL(String inFilename) {
String key = "/gs/" + BUCKETNAME + "/" + inFilename;
ImagesService imagesService = ImagesServiceFactory.getImagesService();
ServingUrlOptions options = ServingUrlOptions.Builder.withGoogleStorageFileName(key);
String servingUrl = imagesService.getServingUrl(options);
return servingUrl;
}
我試圖將圖像公之於眾,但這並沒有幫助。 我在這里看了很多答案,但我有點失落。 任何幫助,將不勝感激
我也遇到了同樣的問題。 對於未來的人,請確保您公開了這個桶。 通過相同的方法,您還可以為圖像生成縮略圖和安全網址
public static String getImageURL(String inFilename) {
String key = "/gs/" + BUCKETNAME + "/" + inFilename;
ImagesService imagesService = ImagesServiceFactory.getImagesService();
ServingUrlOptions options = ServingUrlOptions.Builder
.withGoogleStorageFileName(key).imageSize(150).secureUrl(true);
String servingUrl = imagesService.getServingUrl(options);
return servingUrl;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.