Пример #1
0
func (command *commandUploadDir) handle(p string, params *paramsUploadDir) *handler.Resource {
	re := &handler.Resource{}

	file, err := os.Open(p)
	defer file.Close()

	if err != nil {
		re.Err = err
		return re
	}

	on := strings.TrimPrefix(p, params.dir+string(os.PathSeparator))
	res := objects.Create(command.Ctx.ServiceClient, params.container, on, file, params.opts)
	re.Err = res.Err

	if res.Err == nil {
		if params.quiet == true {
			re.Result = ""
		} else {
			re.Result = fmt.Sprintf("Uploaded %s to %s", on, params.container)
		}
	}

	return re
}
Пример #2
0
// Create is a function that creates a new object or replaces an existing object.
func Create(c *gophercloud.ServiceClient, containerName, objectName string, content io.ReadSeeker, opts os.CreateOptsBuilder) os.CreateResult {
	return os.Create(c, containerName, objectName, content, opts)
}