|
@@ -25,33 +25,29 @@ type (
|
|
|
|
|
|
DeleteMultiObjJsonBody struct {
|
|
|
ConfigKey
|
|
|
- ObjNames []string `json:"objNames" binding:"required"`
|
|
|
- UserID string `json:"userId"`
|
|
|
- OperatorUserName string `json:"operatorUserName" assign:"toField:OperatorUserName"`
|
|
|
+ ObjNames []string `json:"objNames" binding:"required"`
|
|
|
+ Prefix string `json:"prefix"`
|
|
|
}
|
|
|
CopyJsonBody struct {
|
|
|
ConfigKey
|
|
|
- SrcObjName string `json:"srcObjName" binding:"required"`
|
|
|
- DstObjName string `json:"dstObjName" binding:"required"`
|
|
|
- RequireInfos []string `json:"requireInfos"`
|
|
|
- CreateUserID string `json:"createUserId" assign:"toField:CreateUserID"`
|
|
|
- OperatorUserName string `json:"operatorUserName" assign:"toField:OperatorUserName"`
|
|
|
+ SrcObjName string `json:"srcObjName" binding:"required"`
|
|
|
+ DstObjName string `json:"dstObjName" binding:"required"`
|
|
|
+ RequireInfos []string `json:"requireInfos"`
|
|
|
+ Prefix string `json:"prefix"`
|
|
|
}
|
|
|
MoveJsonBody struct {
|
|
|
ConfigKey
|
|
|
- SrcObjName string `json:"srcObjName" binding:"required"`
|
|
|
- DstObjName string `json:"dstObjName" binding:"required"`
|
|
|
- RequireInfos []string `json:"requireInfos"`
|
|
|
- UpdateUserID string `json:"updateUserId" assign:"toField:LastUpdateUserID"`
|
|
|
- OperatorUserName string `json:"operatorUserName" assign:"toField:OperatorUserName"`
|
|
|
+ SrcObjName string `json:"srcObjName" binding:"required"`
|
|
|
+ DstObjName string `json:"dstObjName" binding:"required"`
|
|
|
+ RequireInfos []string `json:"requireInfos"`
|
|
|
+ Prefix string `json:"prefix"`
|
|
|
}
|
|
|
ZoomUrlJsonBody struct {
|
|
|
ConfigKey
|
|
|
- ObjName string `json:"srcObjName" binding:"required"`
|
|
|
- Process string `json:"dstObjName" binding:"required"`
|
|
|
- RequireInfos []string `json:"requireInfos"`
|
|
|
- CreateUserID string `json:"createUserId" assign:"toField:CreateUserID"`
|
|
|
- OperatorUserName string `json:"operatorUserName" assign:"toField:OperatorUserName"`
|
|
|
+ ObjName string `json:"srcObjName" binding:"required"`
|
|
|
+ Process string `json:"dstObjName" binding:"required"`
|
|
|
+ RequireInfos []string `json:"requireInfos"`
|
|
|
+ Prefix string `json:"prefix"`
|
|
|
}
|
|
|
)
|
|
|
|
|
@@ -86,15 +82,15 @@ func Init(configPrefix, configNamespace, configName, baseUrl string) error {
|
|
|
// return Bkt.PutObject(to, reader)
|
|
|
//}
|
|
|
|
|
|
-func GetUrl(objName, userId string) (string, error) {
|
|
|
- return getUrl(objName, userId)
|
|
|
+func GetUrl(objName string) (string, error) {
|
|
|
+ return getUrl(objName)
|
|
|
}
|
|
|
|
|
|
-func GetUrlWithPrefix(objName, userId string) (string, error) {
|
|
|
- return getUrl(prefix+objName, userId)
|
|
|
+func GetUrlWithPrefix(objName string) (string, error) {
|
|
|
+ return getUrl(prefix + objName)
|
|
|
}
|
|
|
|
|
|
-func getUrl(objName, userId string) (string, error) {
|
|
|
+func getUrl(objName string) (string, error) {
|
|
|
if strutils.IsStringEmpty(objName) {
|
|
|
return "", nil
|
|
|
}
|
|
@@ -103,7 +99,6 @@ func getUrl(objName, userId string) (string, error) {
|
|
|
"namespace": namespace,
|
|
|
"name": name,
|
|
|
"objName": objName,
|
|
|
- "userId": userId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return "", err
|
|
@@ -145,14 +140,14 @@ func getUrl(objName, userId string) (string, error) {
|
|
|
//}
|
|
|
|
|
|
func ZoomUrl(objName, profess string) (string, error) {
|
|
|
- return zoomlUrl(objName, profess)
|
|
|
+ return zoomUrl(objName, profess)
|
|
|
}
|
|
|
|
|
|
func ZoomUrlWithPrefix(objName, profess string) (string, error) {
|
|
|
- return zoomlUrl(prefix+objName, profess)
|
|
|
+ return zoomUrl(prefix+objName, profess)
|
|
|
}
|
|
|
|
|
|
-func zoomlUrl(objName, process string) (string, error) {
|
|
|
+func zoomUrl(objName, process string) (string, error) {
|
|
|
if strutils.IsStringEmpty(objName) {
|
|
|
return "", nil
|
|
|
}
|
|
@@ -197,15 +192,15 @@ func zoomlUrl(objName, process string) (string, error) {
|
|
|
// return Bkt.IsObjectExist(prefix + obj)
|
|
|
//}
|
|
|
|
|
|
-func Exist(objName, userId string) (bool, error) {
|
|
|
- return exist(objName, userId)
|
|
|
+func Exist(objName string) (bool, error) {
|
|
|
+ return exist(objName)
|
|
|
}
|
|
|
|
|
|
-func ExistWithPrefix(objName, userId string) (bool, error) {
|
|
|
- return exist(prefix+objName, userId)
|
|
|
+func ExistWithPrefix(objName string) (bool, error) {
|
|
|
+ return exist(prefix + objName)
|
|
|
}
|
|
|
|
|
|
-func exist(objName, userId string) (bool, error) {
|
|
|
+func exist(objName string) (bool, error) {
|
|
|
if strutils.IsStringEmpty(objName) {
|
|
|
return false, nil
|
|
|
}
|
|
@@ -213,7 +208,6 @@ func exist(objName, userId string) (bool, error) {
|
|
|
"namespace": namespace,
|
|
|
"name": name,
|
|
|
"objName": objName,
|
|
|
- "userId": userId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return false, err
|
|
@@ -232,8 +226,8 @@ func exist(objName, userId string) (bool, error) {
|
|
|
return true, nil
|
|
|
}
|
|
|
|
|
|
-func DeleteMulti(userId string, objNames ...string) error {
|
|
|
- return deleteMulti(userId, objNames...)
|
|
|
+func DeleteMulti(objNames ...string) error {
|
|
|
+ return deleteMulti(objNames...)
|
|
|
}
|
|
|
|
|
|
func DeleteMultiWithPrefix(userId string, objNames ...string) error {
|
|
@@ -241,10 +235,10 @@ func DeleteMultiWithPrefix(userId string, objNames ...string) error {
|
|
|
objName = prefix + objName
|
|
|
}
|
|
|
|
|
|
- return deleteMulti(userId, objNames...)
|
|
|
+ return deleteMulti(objNames...)
|
|
|
}
|
|
|
|
|
|
-func deleteMulti(userId string, objNames ...string) error {
|
|
|
+func deleteMulti(objNames ...string) error {
|
|
|
if len(objNames) == 0 {
|
|
|
return nil
|
|
|
}
|
|
@@ -254,7 +248,7 @@ func deleteMulti(userId string, objNames ...string) error {
|
|
|
Namespace: namespace,
|
|
|
Name: name,
|
|
|
},
|
|
|
- UserID: userId,
|
|
|
+ Prefix: prefix,
|
|
|
ObjNames: objNames,
|
|
|
})
|
|
|
if err != nil {
|
|
@@ -279,15 +273,15 @@ func deleteMulti(userId string, objNames ...string) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func ListDir(dirPath, userId string) ([]string, error) {
|
|
|
- return listDir(dirPath, userId)
|
|
|
+func ListDir(dirPath string) ([]string, error) {
|
|
|
+ return listDir(dirPath)
|
|
|
}
|
|
|
|
|
|
-func ListDirWithPrefix(dirPath, userId string) ([]string, error) {
|
|
|
- return listDir(prefix+dirPath, userId)
|
|
|
+func ListDirWithPrefix(dirPath string) ([]string, error) {
|
|
|
+ return listDir(prefix + dirPath)
|
|
|
}
|
|
|
|
|
|
-func listDir(dirPath, userId string) ([]string, error) {
|
|
|
+func listDir(dirPath string) ([]string, error) {
|
|
|
if strutils.IsStringEmpty(dirPath) {
|
|
|
return nil, nil
|
|
|
}
|
|
@@ -296,7 +290,6 @@ func listDir(dirPath, userId string) ([]string, error) {
|
|
|
"namespace": namespace,
|
|
|
"name": name,
|
|
|
"dirPath": dirPath,
|
|
|
- "userId": userId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
@@ -315,23 +308,13 @@ func listDir(dirPath, userId string) ([]string, error) {
|
|
|
return resp.Info, 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
|
|
|
-//}
|
|
|
+func LsDetails(dirPath string) ([]ObjectInfo, error) {
|
|
|
+ return lsDetails(dirPath)
|
|
|
+}
|
|
|
+
|
|
|
+func LsDetailsWithPrefix(dirPath string) ([]ObjectInfo, error) {
|
|
|
+ return lsDetails(prefix + dirPath)
|
|
|
+}
|
|
|
|
|
|
type ObjectInfo struct {
|
|
|
Key string
|
|
@@ -339,37 +322,7 @@ type ObjectInfo struct {
|
|
|
Size int64
|
|
|
}
|
|
|
|
|
|
-//func LsDetails(dir string) ([]ObjectInfo, error) {
|
|
|
-// if strutils.HasBlank(dir) {
|
|
|
-// return []ObjectInfo{}, nil
|
|
|
-// }
|
|
|
-//
|
|
|
-// v2, err := Bkt.ListObjectsV2(oss.Prefix(prefix + 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 LsDetails(dirPath, userId string) ([]ObjectInfo, error) {
|
|
|
- return lsDetails(dirPath, userId)
|
|
|
-}
|
|
|
-
|
|
|
-func LsDetailsWithPrefix(dirPath, userId string) ([]ObjectInfo, error) {
|
|
|
- return lsDetails(prefix+dirPath, userId)
|
|
|
-}
|
|
|
-
|
|
|
-func lsDetails(dirPath, userId string) ([]ObjectInfo, error) {
|
|
|
+func lsDetails(dirPath string) ([]ObjectInfo, error) {
|
|
|
if strutils.IsStringEmpty(dirPath) {
|
|
|
return []ObjectInfo{}, nil
|
|
|
}
|
|
@@ -378,7 +331,6 @@ func lsDetails(dirPath, userId string) ([]ObjectInfo, error) {
|
|
|
"namespace": namespace,
|
|
|
"name": name,
|
|
|
"dirPath": dirPath,
|
|
|
- "userId": userId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
@@ -406,30 +358,15 @@ func lsDetails(dirPath, userId string) ([]ObjectInfo, error) {
|
|
|
// return Bkt.DeleteObject(prefix + f)
|
|
|
//}
|
|
|
|
|
|
-func Move(srcObjName, dstObjName, userId string, requireInfos []string) error {
|
|
|
- return move(srcObjName, dstObjName, userId, requireInfos)
|
|
|
+func Move(srcObjName, dstObjName string) error {
|
|
|
+ return move(srcObjName, dstObjName, nil)
|
|
|
}
|
|
|
|
|
|
-func MoveWithPrefix(srcObjName, dstObjName, userId string, requireInfos []string) error {
|
|
|
- return move(prefix+srcObjName, prefix+dstObjName, userId, requireInfos)
|
|
|
-}
|
|
|
-
|
|
|
-func moves(srcObjName, dstObjName, userId string, requireInfos []string) error {
|
|
|
- if strutils.IsStringEmpty(srcObjName) {
|
|
|
- return nil
|
|
|
- }
|
|
|
- if strutils.IsStringEmpty(dstObjName) {
|
|
|
- return nil
|
|
|
- }
|
|
|
- err := copying(srcObjName, dstObjName, requireInfos)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- return deleteMulti(userId, srcObjName)
|
|
|
-
|
|
|
+func MoveWithPrefix(srcObjName, dstObjName string) error {
|
|
|
+ return move(prefix+srcObjName, prefix+dstObjName, nil)
|
|
|
}
|
|
|
|
|
|
-func move(srcObjName, dstObjName, userId string, requireInfos []string) error {
|
|
|
+func move(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
if strutils.IsStringEmpty(srcObjName) {
|
|
|
return nil
|
|
|
}
|
|
@@ -444,6 +381,7 @@ func move(srcObjName, dstObjName, userId string, requireInfos []string) error {
|
|
|
SrcObjName: srcObjName,
|
|
|
DstObjName: dstObjName,
|
|
|
RequireInfos: requireInfos,
|
|
|
+ Prefix: prefix,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -469,12 +407,12 @@ func move(srcObjName, dstObjName, userId string, requireInfos []string) error {
|
|
|
// return err
|
|
|
//}
|
|
|
|
|
|
-func Copy(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
- return copying(srcObjName, dstObjName, requireInfos)
|
|
|
+func Copy(srcObjName, dstObjName string) error {
|
|
|
+ return copying(srcObjName, dstObjName, nil)
|
|
|
}
|
|
|
|
|
|
-func CopyWithPrefix(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
- return copying(prefix+srcObjName, prefix+dstObjName, requireInfos)
|
|
|
+func CopyWithPrefix(srcObjName, dstObjName string) error {
|
|
|
+ return copying(prefix+srcObjName, prefix+dstObjName, nil)
|
|
|
}
|
|
|
|
|
|
func copying(srcObjName, dstObjName string, requireInfos []string) error {
|
|
@@ -493,6 +431,7 @@ func copying(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
SrcObjName: srcObjName,
|
|
|
DstObjName: dstObjName,
|
|
|
RequireInfos: requireInfos,
|
|
|
+ Prefix: prefix,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -516,12 +455,12 @@ func copying(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func CopyPublic(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
- return copyPublic(srcObjName, dstObjName, requireInfos)
|
|
|
+func CopyPublic(srcObjName, dstObjName string) error {
|
|
|
+ return copyPublic(srcObjName, dstObjName, nil)
|
|
|
}
|
|
|
|
|
|
-func CopyPublicWithPrefix(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
- return copyPublic(prefix+srcObjName, prefix+dstObjName, requireInfos)
|
|
|
+func CopyPublicWithPrefix(srcObjName, dstObjName string) error {
|
|
|
+ return copyPublic(prefix+srcObjName, prefix+dstObjName, nil)
|
|
|
}
|
|
|
|
|
|
func copyPublic(srcObjName, dstObjName string, requireInfos []string) error {
|
|
@@ -539,6 +478,7 @@ func copyPublic(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
SrcObjName: srcObjName,
|
|
|
DstObjName: dstObjName,
|
|
|
RequireInfos: requireInfos,
|
|
|
+ Prefix: prefix,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return err
|