main.go 967 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package main
  2. import (
  3. "log"
  4. "github.com/remogatto/cloud"
  5. "gogs.carducci-dante.gov.it/karmen/core/config"
  6. "gogs.carducci-dante.gov.it/karmen/core/generator/generators/list"
  7. )
  8. type Config struct {
  9. config.ConfigT
  10. DocumentName string `yaml:"document_name"`
  11. }
  12. func main() {
  13. conf := new(Config)
  14. err := config.ReadFile("config.yaml", &conf.ConfigT)
  15. if err != nil {
  16. panic(err)
  17. }
  18. log.Printf("Connecting to the cloud...")
  19. client, err := cloud.Dial(
  20. conf.Cloud.Url,
  21. conf.Cloud.Username,
  22. conf.Cloud.Password,
  23. )
  24. if err != nil {
  25. log.Println(err)
  26. }
  27. err = client.Mkdir("Documents/Example 2")
  28. if err != nil {
  29. panic(err)
  30. }
  31. // Upload resources on the cloud
  32. if files, err := client.UploadDir("resources/*", "Documents/Example 2"); err != nil {
  33. panic(err)
  34. } else {
  35. for _, file := range files {
  36. log.Println(file, " was uploaded.")
  37. }
  38. }
  39. gen := list.NewListGenerator(&conf.ConfigT)
  40. gen.CloudPath = "Documents/Example 2"
  41. gen.Run()
  42. }