Exemple #1
0
// ContainerCDNMeta returns the CDN metadata for a container.
func (c *RsConnection) ContainerCDNMeta(container string) (swift.Headers, error) {
	resp, headers, err := c.manage(swift.RequestOpts{
		Container:  container,
		Operation:  "HEAD",
		ErrorMap:   swift.ContainerErrorMap,
		NoResponse: true,
		Headers:    swift.Headers{},
	})
	common.Close(resp)
	return headers, err
}
Exemple #2
0
// ContainerCDNDisable disables CDN access to a container.
func (c *RsConnection) ContainerCDNDisable(container string) error {
	h := swift.Headers{"X-CDN-Enabled": "false"}

	resp, _, err := c.manage(swift.RequestOpts{
		Container:  container,
		Operation:  "PUT",
		ErrorMap:   swift.ContainerErrorMap,
		NoResponse: true,
		Headers:    h,
	})
	common.Close(resp)
	return err
}
Exemple #3
0
// ContainerCDNEnable enables a container for public CDN usage.
//
// Change the default TTL of 259200 seconds (72 hours) by passing in an integer value.
//
// This method can be called again to change the TTL.
func (c *RsConnection) ContainerCDNEnable(container string, ttl int) (swift.Headers, error) {
	h := swift.Headers{"X-CDN-Enabled": "true"}
	if ttl > 0 {
		h["X-TTL"] = strconv.Itoa(ttl)
	}

	resp, headers, err := c.manage(swift.RequestOpts{
		Container:  container,
		Operation:  "PUT",
		ErrorMap:   swift.ContainerErrorMap,
		NoResponse: true,
		Headers:    h,
	})
	common.Close(resp)
	return headers, err
}