Google app engine google存储BlobKeyForFile错误

Google app engine google存储BlobKeyForFile错误,google-app-engine,go,google-cloud-storage,Google App Engine,Go,Google Cloud Storage,我试图通过谷歌从谷歌存储服务图像 为了做到这一点,我需要创建blob键 我尝试了几种生成密钥的方法,但都出现了错误 loc := fmt.Sprintf("/gs/%s/%s", BUCKET, s) applog.Infof(appCtx, "%s", loc) bkey, err := blobstore.BlobKeyForFile(appCtx, loc) if err != nil { gc.JSON(500, model.GenericResponse{500, err.Er

我试图通过谷歌从谷歌存储服务图像

为了做到这一点,我需要创建blob键

我尝试了几种生成密钥的方法,但都出现了错误

loc := fmt.Sprintf("/gs/%s/%s", BUCKET, s)
applog.Infof(appCtx, "%s", loc)
bkey, err := blobstore.BlobKeyForFile(appCtx, loc)
if err != nil {
    gc.JSON(500, model.GenericResponse{500, err.Error()})
    return
}
opt := &image.ServingURLOptions{}
u, err := image.ServingURL(appCtx, bkey, opt)
if err != nil {
    gc.JSON(500, model.GenericResponse{500, err.Error()})
    return
}

// i tried with file extension to 
/gs/bucktname/CXlvJUKiTmo9joe6
OBJECT_NOT_FOUND 

gs://bucktname/rUAJOYKQbORzOYvs
"description": "API error 6 (images: INVALID_BLOB_KEY)"

gs:/bucktname/MlY77iFNbBca2KCA
"description": "API error 6 (images: INVALID_BLOB_KEY)"
  • 正确的道路是什么
  • 图像是否缓存在cdn后面
  • 我也犯了这个错误(除其他错误外),以下是对我有效的修复方法:

  • 将文件保存到Google云存储时,您需要将其公开如下:
    writer.ACL=[]Storage.ACLRule{{{Entity:Storage.AllUsers,Role:Storage.RoleReader}
  • 正确的路径是
    fmt.Sprintf(“/gs/%s/%s”,bucketName,objectName)
    ,其中objectName是bucket中文件的路径
  • 你必须公开这个桶。有关如何执行此操作的说明,请参见

  • 我现在也有同样的问题。你找到答案了吗?令人困惑的是,它在本地模拟appengine上运行时有效,但在实际应用中失败。