mirror of
https://github.com/KevinMidboe/planetposen-images.git
synced 2025-10-29 13:20:11 +00:00
App for fetching and uploading images to cloud bucket storage
This commit is contained in:
23
clients/gcs/types.go
Normal file
23
clients/gcs/types.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user