mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-18 15:59:01 +08:00
mongo
This commit is contained in:
+15
-1
@@ -1,6 +1,11 @@
|
||||
package utils
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Determine whether the given path is a folder
|
||||
func IsDir(path string) bool {
|
||||
@@ -20,3 +25,12 @@ func IsFile(path string) bool {
|
||||
func MkDir(path string) error {
|
||||
return os.MkdirAll(path, os.ModePerm)
|
||||
}
|
||||
|
||||
func GetNewFileNameAndContentType(fileType string) (string, string) {
|
||||
newName := fmt.Sprintf("%d-%d%s", time.Now().UnixNano(), rand.Int(), fileType)
|
||||
contentType := ""
|
||||
if fileType == "img" {
|
||||
contentType = "image/" + fileType[1:]
|
||||
}
|
||||
return newName, contentType
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user