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

23
clients/gcs/types.go Normal file
View File

@@ -0,0 +1,23 @@
package gcs
import "encoding/base64"
// RawPath is a raw path to a file in GCS
type RawPath string
// EncodedPath is base64-encoded version of RawPath
type EncodedPath string
// Encode base64-encodes raw paths
func (p RawPath) Encode() EncodedPath {
return EncodedPath(base64.StdEncoding.EncodeToString([]byte(p)))
}
// Decode base64-decodes encoded paths
func (p EncodedPath) Decode() (RawPath, error) {
decoded, err := base64.StdEncoding.DecodeString(string(p))
if err != nil {
return "", err
}
return RawPath(decoded), nil
}