Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bwallet
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Go
bwallet
Commits
648438c7
Commit
648438c7
authored
Dec 25, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
66a3125c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
6 deletions
+56
-6
setting.go
pkg/setting/setting.go
+9
-0
upload.go
routers/api/v1/upload.go
+42
-0
router.go
routers/router.go
+5
-6
No files found.
pkg/setting/setting.go
View file @
648438c7
...
@@ -61,6 +61,15 @@ type Redis struct {
...
@@ -61,6 +61,15 @@ type Redis struct {
var
RedisSetting
=
&
Redis
{}
var
RedisSetting
=
&
Redis
{}
type
Oss
struct
{
AccessKeyId
string
AccessKeySecret
string
Endpoint
string
Bucket
string
}
var
OssSetting
=
&
Oss
{}
var
cfg
*
ini
.
File
var
cfg
*
ini
.
File
// Setup initialize the configuration instance
// Setup initialize the configuration instance
...
...
routers/api/v1/upload.go
0 → 100644
View file @
648438c7
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
}
routers/router.go
View file @
648438c7
...
@@ -3,9 +3,6 @@ package routers
...
@@ -3,9 +3,6 @@ package routers
import
(
import
(
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"net/http"
"bwallet/pkg/upload"
"bwallet/pkg/qrcode"
"bwallet/routers/api"
"bwallet/routers/api"
"bwallet/routers/api/v1"
"bwallet/routers/api/v1"
"bwallet/middleware/auth"
"bwallet/middleware/auth"
...
@@ -18,16 +15,18 @@ func InitRouter() *gin.Engine {
...
@@ -18,16 +15,18 @@ func InitRouter() *gin.Engine {
r
.
Use
(
gin
.
Recovery
())
r
.
Use
(
gin
.
Recovery
())
r
.
StaticFS
(
"/upload/images"
,
http
.
Dir
(
upload
.
GetImageFullPath
()))
//
r.StaticFS("/upload/images", http.Dir(upload.GetImageFullPath()))
r
.
StaticFS
(
"/qrcode"
,
http
.
Dir
(
qrcode
.
GetQrCodeFullPath
()))
//
r.StaticFS("/qrcode", http.Dir(qrcode.GetQrCodeFullPath()))
r
.
POST
(
"/auth"
,
api
.
GetAuth
)
r
.
POST
(
"/auth"
,
api
.
GetAuth
)
r
.
POST
(
"/upload"
,
api
.
UploadImage
)
//
r.POST("/upload", api.UploadImage)
api
:=
r
.
Group
(
"/api"
)
api
:=
r
.
Group
(
"/api"
)
api
.
Use
(
auth
.
AUTH
())
api
.
Use
(
auth
.
AUTH
())
{
{
api
.
POST
(
"/upload"
,
v1
.
UploadImage
)
api
.
GET
(
"/coins"
,
v1
.
GetCoins
)
api
.
GET
(
"/coins"
,
v1
.
GetCoins
)
api
.
POST
(
"/coin"
,
v1
.
AddCoin
)
api
.
POST
(
"/coin"
,
v1
.
AddCoin
)
api
.
GET
(
"/coin/:id"
,
v1
.
GetCoin
)
api
.
GET
(
"/coin/:id"
,
v1
.
GetCoin
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment