func (c *Client) GetFileFromArchive(id *charm.URL, filename string) (io.ReadCloser, error) {
	fail := func(err error) (io.ReadCloser, error) {
		return nil, err
	}

	// Create the request.
	req, err := http.NewRequest("GET", "", nil)
	if err != nil {
		return fail(errgo.Notef(err, "cannot make new request"))
	}

	// Send the request.
	v := url.Values{}
	if c.statsDisabled {
		v.Set("stats", "0")
	}
	u := url.URL{
		Path:     "/" + id.Path() + "/archive/" + filename,
		RawQuery: v.Encode(),
	}
	resp, err := c.Do(req, u.String())
	if err != nil {
		terr := params.MaybeTermsAgreementError(err)
		if err1, ok := errgo.Cause(terr).(*params.TermAgreementRequiredError); ok {
			terms := strings.Join(err1.Terms, " ")
			return fail(errgo.Newf(`cannot get file from archive because some terms have not been agreed to. Try "juju agree %s"`, terms))
		}
		return fail(errgo.NoteMask(err, "cannot get file from archive", isAPIError))
	}

	return resp.Body, nil
}
// GetFileFromArchive streams the contents of the requested filename from the
// given charm or bundle archive, returning a reader its data can be read from.
GetFileFromArchive streams the contents of the requested filename from the
given charm or bundle archive, returning a reader its data can be read from.
// GetFileFromArchive streams the contents of the requested filename from the // given charm or bundle archive returning a reader its data can be read from .
func (c *Client) GetFileFromArchive(id *charm.URL, filename string) (io.ReadCloser, error) {
	fail := func(err error) (io.ReadCloser, error) {
		return nil, err
	}
	req, err := http.NewRequest("GET", "", nil)
	if err != nil {
		return fail(errgo.Notef(err, "cannot make new request"))
	}
	v := url.Values{}
	if c.statsDisabled {
		v.Set("stats", "0")
	}
	u := url.URL{
		Path:     "/" + id.Path() + "/archive/" + filename,
		RawQuery: v.Encode(),
	}
	resp, err := c.Do(req, u.String())
	if err != nil {
		terr := params.MaybeTermsAgreementError(err)
		if err1, ok := errgo.Cause(terr).(*params.TermAgreementRequiredError); ok {
			terms := strings.Join(err1.Terms, " ")
			return fail(errgo.Newf(`cannot get file from archive because some terms have not been agreed to. Try "juju agree %s"`, terms))
		}
		return fail(errgo.NoteMask(err, "cannot get file from archive", isAPIError))
	}
	return resp.Body, nil
}
func ( c * Client ) GetFileFromArchive ( id * charm . URL , filename string ) ( io . ReadCloser , error ) { fail := func ( err error ) ( io . ReadCloser , error ) { return nil , err } req , err := http . NewRequest ( " " , " " , nil ) if err != nil { return fail ( errgo . Notef ( err , " " ) ) } v := url . Values { } if c . statsDisabled { v . Set ( " " , " " ) } u := url . URL { Path : " " + id . Path ( ) + " " + filename , RawQuery : v . Encode ( ) , } resp , err := c . Do ( req , u . String ( ) ) if err != nil { terr := params . MaybeTermsAgreementError ( err ) if err1 , ok := errgo . Cause ( terr ) . ( * params . TermAgreementRequiredError ) ; ok { terms := strings . Join ( err1 . Terms , " " ) return fail ( errgo . Newf ( `cannot get file from archive because some terms have not been agreed to. Try "juju agree %s"` , terms ) ) } return fail ( errgo . NoteMask ( err , " " , isAPIError ) ) } return resp . Body , nil }
GetFileFromArchive streams the contents of the requested filename from the
given charm or bundle archive, returning a reader its data can be read from.
GetFileFromArchive streams the contents of the requested filename from the given charm or bundle archive returning a reader its data can be read from .
// Create the request. // Send the request.