Exemplo n.º 1
0
func (command *commandDownload) Execute(resource *handler.Resource) {
	containerName := resource.Params.(*paramsDownload).container
	objectName := resource.Params.(*paramsDownload).object
	rawResponse := objects.Download(command.Ctx.ServiceClient, containerName, objectName, nil)
	if rawResponse.Err != nil {
		resource.Err = rawResponse.Err
		return
	}
	resource.Result = rawResponse.Body
}
Exemplo n.º 2
0
func (command *commandDownload) Execute(resource *handler.Resource) {
	containerName := resource.Params.(*paramsDownload).container
	objectName := resource.Params.(*paramsDownload).object
	rawResponse := objects.Download(command.Ctx.ServiceClient, containerName, objectName, nil)
	if rawResponse.Err != nil {
		resource.Err = rawResponse.Err
		return
	}
	if command.Ctx.CLIContext.IsSet("json") {
		bytes, err := ioutil.ReadAll(rawResponse.Body)
		if err != nil {
			resource.Err = err
			return
		}
		resource.Result = string(bytes)
	} else {
		resource.Result = rawResponse.Body
	}
}