使用软件包文件写入Cloud Storage?

Golang provides the file package to access Cloud Storage.

The package's Create function requires the io.WriteCloser interface. However, I have not found a single sample or documentation showing how to actually save a file to Cloud Storage.

Can anybody help? Is there a higher level implementation of io.WriteCloser that would allow us to store files in Cloud Storage? Any sample code?

We've obviously tried to Google it ourselves but found nothing and now hope for the community to help.

It's perhaps true than the behavior is not well defined in the documentation.

If you check the code: https://code.google.com/p/appengine-go/source/browse/appengine/file/write.go#133

In each call to Write the data is sent to the cloud (line 139). So you don't need to save. (You should close the file when you're done, through.)

Anyway, I'm confused with your wording: "The package's Create function requires the io.WriteCloser interface." That's not true. The package's Create functions returns a io.WriteCloser, that is, a thingy you can write to and close.

yourFile, _, err := Create(ctx, "filename", nil)
// Check err != nil here.

defer func() {
    err := yourFile.Close()
    // Check err != nil here.
}()

yourFile.Write([]byte("This will be sent to the file immediately."))
fmt.Fprintln(yourFile, "This too.")
io.Copy(yourFile, someReader)

This is how interfaces work in Go. They just provide you with a set of methods you can call, hiding the actual implementation from you; and, when you just depend on a particular interface instead of a particular implementation, you can combine in multiple ways, as fmt.Fprintln and io.Copy do.