|
@@ -15,8 +15,11 @@ import (
|
|
|
"os"
|
|
|
"path"
|
|
|
"regexp"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
+
|
|
|
+ rdHttp "github.com/rdlucklib/rdluck_tools/http"
|
|
|
)
|
|
|
|
|
|
// 资源管理-图片上传,合同上传等
|
|
@@ -1090,3 +1093,31 @@ func (this *ResourceAuthController) FileDownload() {
|
|
|
br.Success = true
|
|
|
this.Ctx.Output.Download(localFilePath, fileName)
|
|
|
}
|
|
|
+
|
|
|
+// FileDownload
|
|
|
+// @Title 文件加载
|
|
|
+// @Description 文件加载
|
|
|
+// @Param FileUrl query string true "文件路径"
|
|
|
+// @Success 200 Ret=200 操作成功
|
|
|
+// @router /file/reload [get]
|
|
|
+func (this *ResourceController) FileReload() {
|
|
|
+
|
|
|
+ fileUrl := `https://hzstatic.hzinsights.com/static/images/202202/20220208/Qr3dulOoVTJgyl8skH1jL1kv36RX.png`
|
|
|
+
|
|
|
+ body, err := rdHttp.Get(fileUrl)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("err: ", err)
|
|
|
+ this.Ctx.WriteString("err: " + err.Error() + "")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 设置响应头
|
|
|
+ this.Ctx.ResponseWriter.Header().Set("Content-Type", "image/png")
|
|
|
+ this.Ctx.ResponseWriter.Header().Set("Content-Length", strconv.Itoa(len(body)))
|
|
|
+
|
|
|
+ // 将文件内容写入响应体
|
|
|
+ _, err = this.Ctx.ResponseWriter.Write(body)
|
|
|
+ if err != nil {
|
|
|
+ http.Error(this.Ctx.ResponseWriter, "Failed to write response", http.StatusInternalServerError)
|
|
|
+ return
|
|
|
+ }
|
|
|
+}
|