Browse Source

Merge branch 'master' of https://git.sxidc.com/go-tools/utils

yjp 3 months ago
parent
commit
3e89c94ba6
1 changed files with 18 additions and 0 deletions
  1. 18 0
      oss/oss.go

+ 18 - 0
oss/oss.go

@@ -134,6 +134,24 @@ func Ls(dir string) ([]string, error) {
 	return ks, nil
 }
 
+func LsWithoutPrefix(dir string) ([]string, error) {
+	if strutils.HasBlank(dir) {
+		return []string{}, nil
+	}
+
+	v2, err := Bkt.ListObjectsV2(oss.Prefix(dir))
+	if err != nil {
+		return nil, err
+	}
+
+	ks := make([]string, len(v2.Objects))
+	for i, obj := range v2.Objects {
+		ks[i] = obj.Key
+	}
+
+	return ks, nil
+}
+
 type ObjectInfo struct {
 	Key  string
 	Type string