Initial Commit

This commit is contained in:
2023-08-16 14:16:16 -04:00
commit 0f1f983532
4 changed files with 119 additions and 0 deletions

44
main.go Normal file
View File

@@ -0,0 +1,44 @@
package main
import (
"github.com/joho/godotenv"
"log"
"os"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
)
func main() {
accessKeyID, secretAccessKey := getCredentials()
endpoint := "s3.us-west-002.backblazeb2.com"
// Initialize minio client object.
minioClient, err := minio.New(endpoint, &minio.Options{
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
Secure: true,
})
if err != nil {
log.Fatalln(err)
}
log.Printf("%#v\n", minioClient) // minioClient is now set up
}
func getCredentials() (string, string) {
// get credentials from env vars
err := godotenv.Load()
if err != nil {
log.Fatalf("error loading .env file: (%s)", err.Error())
}
keyName := os.Getenv("KEY_NAME")
if keyName == "" {
log.Fatal("missing or empty KEY_NAME")
}
applicationKey := os.Getenv("APPLICATION_KEY")
if applicationKey == "" {
log.Fatal("missing or empty APPLICATION_KEY")
}
return keyName, applicationKey
}