mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 11:20:18 +08:00
Add escapePath for getUploadFileUrl().
This commit is contained in:
@ -17,6 +17,7 @@ package object
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/casdoor/casdoor/conf"
|
||||
@ -42,8 +43,19 @@ func getProviderEndpoint(provider *Provider) string {
|
||||
return endpoint
|
||||
}
|
||||
|
||||
func escapePath(path string) string {
|
||||
tokens := strings.Split(path, "/")
|
||||
if len(tokens) > 0 {
|
||||
tokens[len(tokens)-1] = url.QueryEscape(tokens[len(tokens)-1])
|
||||
}
|
||||
|
||||
res := strings.Join(tokens, "/")
|
||||
return res
|
||||
}
|
||||
|
||||
func getUploadFileUrl(provider *Provider, fullFilePath string, hasTimestamp bool) (string, string) {
|
||||
objectKey := util.UrlJoin(util.GetUrlPath(provider.Domain), fullFilePath)
|
||||
escapedPath := escapePath(fullFilePath)
|
||||
objectKey := util.UrlJoin(util.GetUrlPath(provider.Domain), escapedPath)
|
||||
|
||||
host := ""
|
||||
if provider.Type != "Local File System" {
|
||||
|
Reference in New Issue
Block a user