英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论