2 Commits 34a318e773 ... d281074a6a

Author SHA1 Message Date
  duyong mac d281074a6a Merge branch 'master' of https://git.sxidc.com/go-tools/utils 4 months ago
  duyong mac bc0be65b25 oss增加函数 4 months ago
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