file.go 891 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2014 Google Inc. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. // Package file provides helper functions for using Google Cloud Storage.
  5. package file
  6. import (
  7. "fmt"
  8. "golang.org/x/net/context"
  9. "google.golang.org/appengine/internal"
  10. aipb "google.golang.org/appengine/internal/app_identity"
  11. )
  12. // DefaultBucketName returns the name of this application's
  13. // default Google Cloud Storage bucket.
  14. func DefaultBucketName(c context.Context) (string, error) {
  15. req := &aipb.GetDefaultGcsBucketNameRequest{}
  16. res := &aipb.GetDefaultGcsBucketNameResponse{}
  17. err := internal.Call(c, "app_identity_service", "GetDefaultGcsBucketName", req, res)
  18. if err != nil {
  19. return "", fmt.Errorf("file: no default bucket name returned in RPC response: %v", res)
  20. }
  21. return res.GetDefaultGcsBucketName(), nil
  22. }