Commit 648438c7 authored by shajiaiming's avatar shajiaiming

fix

parent 66a3125c
......@@ -61,6 +61,15 @@ type Redis struct {
var RedisSetting = &Redis{}
type Oss struct {
AccessKeyId string
AccessKeySecret string
Endpoint string
Bucket string
}
var OssSetting = &Oss{}
var cfg *ini.File
// Setup initialize the configuration instance
......
package v1
import (
"github.com/gin-gonic/gin"
"net/http"
"bwallet/pkg/app"
"bwallet/pkg/e"
"bwallet/pkg/setting"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"fmt"
"os"
)
func UploadImage(c *gin.Context) {
appG := app.Gin{C: c}
file, image, err := c.Request.FormFile("image")
if err != nil {
appG.Response(http.StatusInternalServerError, e.ERROR, nil)
return
}
if image == nil {
appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
return
}
accessKeyId := setting.OssSetting.AccessKeyId
accessKeySecret := setting.OssSetting.AccessKeySecret
endpoint := setting.OssSetting.Endpoint
//bucket := setting.OssSetting.Bucket
client, err := oss.New(endpoint, accessKeyId, accessKeySecret)
if err != nil {
fmt.Println(err)
os.Exit(0)
appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
return
}
fmt.Println(client)
os.Exit(0)
return
}
......@@ -3,9 +3,6 @@ package routers
import (
"github.com/gin-gonic/gin"
"net/http"
"bwallet/pkg/upload"
"bwallet/pkg/qrcode"
"bwallet/routers/api"
"bwallet/routers/api/v1"
"bwallet/middleware/auth"
......@@ -18,16 +15,18 @@ func InitRouter() *gin.Engine {
r.Use(gin.Recovery())
r.StaticFS("/upload/images", http.Dir(upload.GetImageFullPath()))
r.StaticFS("/qrcode", http.Dir(qrcode.GetQrCodeFullPath()))
//r.StaticFS("/upload/images", http.Dir(upload.GetImageFullPath()))
//r.StaticFS("/qrcode", http.Dir(qrcode.GetQrCodeFullPath()))
r.POST("/auth", api.GetAuth)
r.POST("/upload", api.UploadImage)
//r.POST("/upload", api.UploadImage)
api := r.Group("/api")
api.Use(auth.AUTH())
{
api.POST("/upload",v1.UploadImage)
api.GET("/coins", v1.GetCoins)
api.POST("/coin", v1.AddCoin)
api.GET("/coin/:id", v1.GetCoin)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment