Просмотр исходного кода

chore(stdiscosrv): path style s3

Jakob Borg 10 месяцев назад
Родитель
Сommit
c74299b59a
2 измененных файлов с 7 добавлено и 6 удалено
  1. 3 3
      cmd/stdiscosrv/database.go
  2. 4 3
      lib/s3/s3.go

+ 3 - 3
cmd/stdiscosrv/database.go

@@ -74,16 +74,16 @@ func newInMemoryStore(dir string, flushInterval time.Duration, s3sess *s3.Sessio
 		// Try to read from AWS
 		latestKey, cerr := s3sess.LatestKey()
 		if cerr != nil {
-			log.Println("Error reading database from S3:", err)
+			log.Println("Error finding database from S3:", cerr)
 			return s
 		}
 		fd, cerr := os.Create(path.Join(s.dir, "records.db"))
 		if cerr != nil {
-			log.Println("Error creating database file:", err)
+			log.Println("Error creating database file:", cerr)
 			return s
 		}
 		if cerr := s3sess.Download(fd, latestKey); cerr != nil {
-			log.Printf("Error reading database from S3: %v", err)
+			log.Printf("Error downloading database from S3: %v", cerr)
 		}
 		_ = fd.Close()
 		nr, err = s.read()

+ 4 - 3
lib/s3/s3.go

@@ -26,9 +26,10 @@ type Object = s3.Object
 
 func NewSession(endpoint, region, bucket, accessKeyID, secretKey string) (*Session, error) {
 	sess, err := session.NewSession(&aws.Config{
-		Region:      aws.String(region),
-		Endpoint:    aws.String(endpoint),
-		Credentials: credentials.NewStaticCredentials(accessKeyID, secretKey, ""),
+		Region:           aws.String(region),
+		Endpoint:         aws.String(endpoint),
+		Credentials:      credentials.NewStaticCredentials(accessKeyID, secretKey, ""),
+		S3ForcePathStyle: aws.Bool(true),
 	})
 	if err != nil {
 		return nil, err