|
|
@@ -4,9 +4,6 @@ import ( |
|
|
|
"applet/app/e" |
|
|
|
"applet/app/svc" |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"io" |
|
|
|
"net/http" |
|
|
|
"os" |
|
|
|
) |
|
|
|
|
|
|
|
func Demo(c *gin.Context) { |
|
|
@@ -24,49 +21,3 @@ func Demo(c *gin.Context) { |
|
|
|
}, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
func Demo1(c *gin.Context) { |
|
|
|
path := "/data/advertisement-pdf" |
|
|
|
imgUrl := "http://miniapp.bianxian.com/_0000000000_2024103011290507244911708.ttf" |
|
|
|
|
|
|
|
// Get the data |
|
|
|
resp, err := http.Get(imgUrl) |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
defer resp.Body.Close() |
|
|
|
|
|
|
|
// 创建一个文件用于保存 |
|
|
|
out, err := os.Create(path + "/_0000000000_2024103011290507244911708.ttf") |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
defer out.Close() |
|
|
|
|
|
|
|
// 然后将响应流和文件流对接起来 |
|
|
|
_, err = io.Copy(out, resp.Body) |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
imgUrl1 := "http://miniapp.bianxian.com/_0000000000_2024103011210157735330925.png" |
|
|
|
|
|
|
|
// Get the data |
|
|
|
resp1, err1 := http.Get(imgUrl1) |
|
|
|
if err1 != nil { |
|
|
|
panic(err1) |
|
|
|
} |
|
|
|
defer resp.Body.Close() |
|
|
|
|
|
|
|
// 创建一个文件用于保存 |
|
|
|
out1, err1 := os.Create(path + "/_0000000000_2024103011210157735330925.png") |
|
|
|
if err1 != nil { |
|
|
|
panic(err1) |
|
|
|
} |
|
|
|
defer out.Close() |
|
|
|
|
|
|
|
// 然后将响应流和文件流对接起来 |
|
|
|
_, err1 = io.Copy(out1, resp.Body) |
|
|
|
if err1 != nil { |
|
|
|
panic(err1) |
|
|
|
} |
|
|
|
return |
|
|
|
} |