|
@@ -25,33 +25,29 @@ type (
|
|
|
|
|
|
DeleteMultiObjJsonBody struct {
|
|
DeleteMultiObjJsonBody struct {
|
|
ConfigKey
|
|
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 {
|
|
CopyJsonBody struct {
|
|
ConfigKey
|
|
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 {
|
|
MoveJsonBody struct {
|
|
ConfigKey
|
|
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 {
|
|
ZoomUrlJsonBody struct {
|
|
ConfigKey
|
|
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)
|
|
// 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) {
|
|
if strutils.IsStringEmpty(objName) {
|
|
return "", nil
|
|
return "", nil
|
|
}
|
|
}
|
|
@@ -103,7 +99,6 @@ func getUrl(objName, userId string) (string, error) {
|
|
"namespace": namespace,
|
|
"namespace": namespace,
|
|
"name": name,
|
|
"name": name,
|
|
"objName": objName,
|
|
"objName": objName,
|
|
- "userId": userId,
|
|
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
return "", err
|
|
return "", err
|
|
@@ -145,14 +140,14 @@ func getUrl(objName, userId string) (string, error) {
|
|
//}
|
|
//}
|
|
|
|
|
|
func ZoomUrl(objName, profess 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) {
|
|
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) {
|
|
if strutils.IsStringEmpty(objName) {
|
|
return "", nil
|
|
return "", nil
|
|
}
|
|
}
|
|
@@ -197,15 +192,15 @@ func zoomlUrl(objName, process string) (string, error) {
|
|
// return Bkt.IsObjectExist(prefix + obj)
|
|
// 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) {
|
|
if strutils.IsStringEmpty(objName) {
|
|
return false, nil
|
|
return false, nil
|
|
}
|
|
}
|
|
@@ -213,7 +208,6 @@ func exist(objName, userId string) (bool, error) {
|
|
"namespace": namespace,
|
|
"namespace": namespace,
|
|
"name": name,
|
|
"name": name,
|
|
"objName": objName,
|
|
"objName": objName,
|
|
- "userId": userId,
|
|
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
return false, err
|
|
return false, err
|
|
@@ -232,8 +226,8 @@ func exist(objName, userId string) (bool, error) {
|
|
return true, nil
|
|
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 {
|
|
func DeleteMultiWithPrefix(userId string, objNames ...string) error {
|
|
@@ -241,10 +235,10 @@ func DeleteMultiWithPrefix(userId string, objNames ...string) error {
|
|
objName = prefix + objName
|
|
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 {
|
|
if len(objNames) == 0 {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
@@ -254,7 +248,7 @@ func deleteMulti(userId string, objNames ...string) error {
|
|
Namespace: namespace,
|
|
Namespace: namespace,
|
|
Name: name,
|
|
Name: name,
|
|
},
|
|
},
|
|
- UserID: userId,
|
|
|
|
|
|
+ Prefix: prefix,
|
|
ObjNames: objNames,
|
|
ObjNames: objNames,
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -279,15 +273,15 @@ func deleteMulti(userId string, objNames ...string) error {
|
|
return nil
|
|
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) {
|
|
if strutils.IsStringEmpty(dirPath) {
|
|
return nil, nil
|
|
return nil, nil
|
|
}
|
|
}
|
|
@@ -296,7 +290,6 @@ func listDir(dirPath, userId string) ([]string, error) {
|
|
"namespace": namespace,
|
|
"namespace": namespace,
|
|
"name": name,
|
|
"name": name,
|
|
"dirPath": dirPath,
|
|
"dirPath": dirPath,
|
|
- "userId": userId,
|
|
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
@@ -315,23 +308,13 @@ func listDir(dirPath, userId string) ([]string, error) {
|
|
return resp.Info, nil
|
|
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 {
|
|
type ObjectInfo struct {
|
|
Key string
|
|
Key string
|
|
@@ -339,37 +322,7 @@ type ObjectInfo struct {
|
|
Size int64
|
|
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) {
|
|
if strutils.IsStringEmpty(dirPath) {
|
|
return []ObjectInfo{}, nil
|
|
return []ObjectInfo{}, nil
|
|
}
|
|
}
|
|
@@ -378,7 +331,6 @@ func lsDetails(dirPath, userId string) ([]ObjectInfo, error) {
|
|
"namespace": namespace,
|
|
"namespace": namespace,
|
|
"name": name,
|
|
"name": name,
|
|
"dirPath": dirPath,
|
|
"dirPath": dirPath,
|
|
- "userId": userId,
|
|
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
@@ -406,30 +358,15 @@ func lsDetails(dirPath, userId string) ([]ObjectInfo, error) {
|
|
// return Bkt.DeleteObject(prefix + f)
|
|
// 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) {
|
|
if strutils.IsStringEmpty(srcObjName) {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
@@ -444,6 +381,7 @@ func move(srcObjName, dstObjName, userId string, requireInfos []string) error {
|
|
SrcObjName: srcObjName,
|
|
SrcObjName: srcObjName,
|
|
DstObjName: dstObjName,
|
|
DstObjName: dstObjName,
|
|
RequireInfos: requireInfos,
|
|
RequireInfos: requireInfos,
|
|
|
|
+ Prefix: prefix,
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
@@ -469,12 +407,12 @@ func move(srcObjName, dstObjName, userId string, requireInfos []string) error {
|
|
// return err
|
|
// 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 {
|
|
func copying(srcObjName, dstObjName string, requireInfos []string) error {
|
|
@@ -493,6 +431,7 @@ func copying(srcObjName, dstObjName string, requireInfos []string) error {
|
|
SrcObjName: srcObjName,
|
|
SrcObjName: srcObjName,
|
|
DstObjName: dstObjName,
|
|
DstObjName: dstObjName,
|
|
RequireInfos: requireInfos,
|
|
RequireInfos: requireInfos,
|
|
|
|
+ Prefix: prefix,
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
@@ -516,12 +455,12 @@ func copying(srcObjName, dstObjName string, requireInfos []string) error {
|
|
return nil
|
|
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 {
|
|
func copyPublic(srcObjName, dstObjName string, requireInfos []string) error {
|
|
@@ -539,6 +478,7 @@ func copyPublic(srcObjName, dstObjName string, requireInfos []string) error {
|
|
SrcObjName: srcObjName,
|
|
SrcObjName: srcObjName,
|
|
DstObjName: dstObjName,
|
|
DstObjName: dstObjName,
|
|
RequireInfos: requireInfos,
|
|
RequireInfos: requireInfos,
|
|
|
|
+ Prefix: prefix,
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|