apkipa 1 week geleden
bovenliggende
commit
61bc5c8f98
2 gewijzigde bestanden met toevoegingen van 131 en 45 verwijderingen
  1. 120 45
      main.go
  2. 11 0
      util/util.go

File diff suppressed because it is too large
+ 120 - 45
main.go


+ 11 - 0
util/util.go

@@ -57,6 +57,17 @@ func LastElem[T any](s []T) T {
 	return s[len(s)-1]
 }
 
+func MinioObjectExists(minioClient *minio.Client, bucketName string, filePath string) (bool, error) {
+	_, err := minioClient.StatObject(context.Background(), bucketName, filePath, minio.StatObjectOptions{})
+	if err != nil {
+		if minio.ToErrorResponse(err).Code == "NoSuchKey" {
+			return false, nil
+		}
+		return false, fmt.Errorf("stat object failed: %w", err)
+	}
+	return true, nil
+}
+
 func MinioUploadFolder(minioClient *minio.Client, bucketName string, objPath string, localPath string) error {
 	// Walk the local folder
 	err := filepath.WalkDir(localPath, func(path string, d os.DirEntry, err error) error {