appengine/file.Delete() 的 fileName 参数应传递什么值?

huangapple go评论89阅读模式
英文:

value to be passed to the fileName of appengine/file.Delete () is?

问题

我想知道在从 GAE/Go 中删除 GCS 文件时,要传递的 fileName 是什么。

尽管传递了 "/gs/{bucketname}/{filename}",但返回了错误消息 "RPC error UNKNOWN_ERROR:"。

package main

import (
    "appengine"
    "appengine/file"
    "net/http"
)

func handle(w http.ResponseWriter, r *http.Request) {
    c := appengine.NewContext(r)

    file.Delete(c, "/gs/{bucketname}/{filename}")
}

以上是要翻译的内容。

英文:

I want to know is fileName to pass when you delete a file of gcs from gae/go.

Although passed "/gs/{bucketname}/{filename}", error message "RPC error UNKNOWN_ERROR:" is returned

package main

import (
    "appengine"
    "appengine/file"

    "net/http"
)

func handle(w http.ResponseWriter, r *http.Request) {
    c := appengine.NewContext(r)

    file.Delete(c, "/gs/{bucketname}/{filename}")
}

答案1

得分: 0

我不是Go的专家,但要使用Cloud Storage,你需要使用Google Cloud Storage Go客户端库,如[1]所示。

请查看这个示例代码[2],特别是deleteFiles()函数。你可以看到删除文件的函数是DeleteObject [3]。

[1] https://cloud.google.com/appengine/docs/go/storage#google_cloud_storage

[2] https://cloud.google.com/appengine/docs/go/googlecloudstorageclient/getstarted

[3] http://godoc.org/google.golang.org/cloud/storage#DeleteObject

英文:

I'm not an expert on Go but to work with Cloud Storage you need the Google Cloud Storage Go Client Library as indicated here [1].

Take a look at this sample code [2], more specifically to the deleteFiles() fuction. You can see that the function to the delete files is DeleteObject [3].

[1] https://cloud.google.com/appengine/docs/go/storage#google_cloud_storage

[2] https://cloud.google.com/appengine/docs/go/googlecloudstorageclient/getstarted

[3] http://godoc.org/google.golang.org/cloud/storage#DeleteObject

huangapple
  • 本文由 发表于 2015年2月23日 21:42:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/28675144.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定