App for fetching and uploading images to cloud bucket storage

This commit is contained in:
2022-12-10 15:27:24 +01:00
commit b56c3d1e29
18 changed files with 749 additions and 0 deletions

8
util/geturl.go Normal file
View File

@@ -0,0 +1,8 @@
package util
import "fmt"
// ImageURL creates imageURL from hostname and image name
func ImageURL(hostname, name string) string {
return fmt.Sprintf("https://%s/api/v1/images/%s", hostname, name)
}

14
util/hash.go Normal file
View File

@@ -0,0 +1,14 @@
package util
import (
"crypto/sha1"
"fmt"
)
// Hash hashes a string using sha1
func Hash(s string) string {
hash := sha1.New()
_, _ = hash.Write([]byte(s))
bs := hash.Sum(nil)
return fmt.Sprintf("%x", bs)
}