mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 04:10:20 +08:00
Add escapePath for getUploadFileUrl().
This commit is contained in:
@ -17,6 +17,7 @@ package object
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/casdoor/casdoor/conf"
|
"github.com/casdoor/casdoor/conf"
|
||||||
@ -42,8 +43,19 @@ func getProviderEndpoint(provider *Provider) string {
|
|||||||
return endpoint
|
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) {
|
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 := ""
|
host := ""
|
||||||
if provider.Type != "Local File System" {
|
if provider.Type != "Local File System" {
|
||||||
|
Reference in New Issue
Block a user