瀏覽代碼

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

yjp 3 月之前
父節點
當前提交
3e89c94ba6
共有 1 個文件被更改,包括 18 次插入0 次删除
  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