示例#1
0
// NewReader creates a new io.ReadCloser to read the contents
// of the object.
func NewReader(ctx context.Context, bucket, name string) (io.ReadCloser, error) {
	c := ctx.Value(internal.Key(0)).(map[string]interface{})["http_client"].(*http.Client)
	resp, err := c.Get(fmt.Sprintf(templURLMedia, bucket, name))
	if err != nil {
		return nil, err
	}
	if resp.StatusCode == http.StatusNotFound {
		return nil, ErrObjectNotExists
	}
	return resp.Body, nil
}
示例#2
0
文件: pubsub.go 项目: qwo/abelana-gcp
func rawService(ctx context.Context) *raw.Service {
	return ctx.Value(internal.Key(0)).(map[string]interface{})["pubsub_service"].(*raw.Service)
}
示例#3
0
文件: pubsub.go 项目: qwo/abelana-gcp
func projID(ctx context.Context) string {
	return ctx.Value(internal.Key(0)).(map[string]interface{})["project_id"].(string)
}