Ver código fonte

oss添加方法

yjp 2 meses atrás
pai
commit
50d7ce75d6
1 arquivos alterados com 28 adições e 0 exclusões
  1. 28 0
      oss/oss.go

+ 28 - 0
oss/oss.go

@@ -134,6 +134,34 @@ func Ls(dir string) ([]string, error) {
 	return ks, nil
 }
 
+type ObjectInfo struct {
+	Key  string
+	Type string
+	Size int64
+}
+
+func LsDetails(dir string) ([]ObjectInfo, error) {
+	if strutils.HasBlank(dir) {
+		return []ObjectInfo{}, nil
+	}
+
+	v2, err := Bkt.ListObjectsV2(oss.Prefix(pfx + dir))
+	if err != nil {
+		return nil, err
+	}
+
+	ks := make([]ObjectInfo, len(v2.Objects))
+	for i, obj := range v2.Objects {
+		ks[i] = ObjectInfo{
+			Key:  obj.Key,
+			Type: obj.Type,
+			Size: obj.Size,
+		}
+	}
+
+	return ks, nil
+}
+
 func Mv(f, t string) error {
 	if err := Cp(f, t); err != nil {
 		return err