From 4c90eaf336a4037f2d497e7b889b2fa21c1a0dd6 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期五, 16 八月 2019 13:34:05 +0800
Subject: [PATCH] img upload use path all
---
middlewares/auth/auth.go | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/middlewares/auth/auth.go b/middlewares/auth/auth.go
index 13f8cc4..b029741 100644
--- a/middlewares/auth/auth.go
+++ b/middlewares/auth/auth.go
@@ -1,6 +1,7 @@
package auth
import (
+ "fmt"
"github.com/gin-gonic/gin"
"net/http"
"strings"
@@ -36,8 +37,18 @@
c.Next()
} else if strings.HasPrefix(urlPath,"/httpImage") {
imgUrl := config.Server.ImageUrl
+ idx := strings.Index(urlPath, ":")
+ tmpPath := urlPath
+ if idx >-1 {//璺緞涓寘鍚湁绔彛,鍙栫鍙d互鍚庤矾寰�
+ tmpPath = urlPath[idx:]
+ imgIndx := strings.Index(imgUrl, ":")
+ if imgIndx > -1 {
+ imgUrl = imgUrl[:imgIndx-1]
+ }
+ }
+ fmt.Println("imgUrl+tmpPath:", imgUrl+tmpPath)
c.Header("Access-Control-Allow-Origin","*")
- c.Redirect(http.StatusMovedPermanently, imgUrl+urlPath[10:])
+ c.Redirect(http.StatusMovedPermanently, imgUrl+tmpPath)
return
} else {
c.Next()
--
Gitblit v1.8.0