func uploadFiles(container string, files []string, c swift.Connection) {
	wpauswiftcommons.CreatePublicContainer(container, c)

	for _, e := range files {
		wpauswiftcommons.UploadFile(container, "", e, c)
	}
}
func downloadFiles(container string, files []string, c swift.Connection) {
	wpauswiftcommons.CreatePublicContainer(container, c)
	names, err := c.ObjectNames(container, nil)

	if err != nil {
		println(err.Error())
		return
	}

	for _, name := range files {
		if !exists(names, name) {
			println("Object does not exists: " + name)
			continue
		}

		f, err := os.Create(name)
		if err != nil {
			println("Couldn't create file: " + name)
			continue
		}
		defer f.Close()

		_, err = c.ObjectGet(container, name, f, true, nil)
		if err != nil {
			println("Couldn't download file: " + name)
		} else {
			println("Downloaded file: " + name)
		}
	}
}
Пример #3
0
func uploadContentsInFolder(path string, prefix string, container string, c swift.Connection) {
	wpauswiftcommons.CreatePublicContainer(container, c)

	err := filepath.Walk(path, func(subpath string, f os.FileInfo, err error) error {
		if !f.IsDir() {
			wpauswiftcommons.UploadFile(container, prefix, subpath, c)
		}
		return nil
	})
	if err != nil {
		println(err.Error())
	}
}