![](/img/trans.png)
[英]How to avoid losing local Google Cloud Storage data after restarting a local App Engine app?
[英]How to access Google Cloud Storage from App Engine in local development environment?
我的代碼在已部署的Google App Engine上運行完美,但在本地調試時則無法運行。 返回的GcsFileMetadata為null,gcsService.openReadChannel(gcsFilename,0)給出FileNotFoundException,下面有更多詳細信息。 總而言之,問題是本地應用引擎無法訪問谷歌雲存儲。 我該如何解決這個問題? 有任何變通方法嗎?
這是代碼
GcsFilename gcsFilename = new GcsFilename(BUCKET_NAME, progress.imageName);
GcsFileMetadata gcsFileMetadata = gcsService.getMetadata(gcsFilename);
if (gcsFileMetadata == null) throw new Exception("gcsService.getMetadata(gcsFilename) returned null");
int fileSize = (int) gcsFileMetadata.getLength();
ByteBuffer byteBuffer = ByteBuffer.allocate(5*1024*1024);
GcsInputChannel gcsInputChannel = gcsService.openReadChannel(gcsFilename, 0);
gcsInputChannel.read(byteBuffer);
在本地調試時,gcsFileMetadata為null,但在部署時工作正常。 我評論出來,我在這一行得到以下錯誤:
GcsInputChannel gcsInputChannel = gcsService.openReadChannel(gcsFilename, 0);
這是錯誤:
java.io.FileNotFoundException: com.google.appengine.tools.cloudstorage.dev.LocalRawGcsService@54381103: No such file: GcsFilename(cloudimagesbucketname, image_20150105_180444)
無法在localhost上訪問Google雲端存儲。 您必須在appengine部署代碼,然后才能訪問GCS服務。 這是來自谷歌的安全服務,無法在localhost訪問。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.