@@ -11,7 +11,6 @@ import ( | |||
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" | |||
"github.com/aliyun/aliyun-oss-go-sdk/oss" | |||
"github.com/gin-gonic/gin" | |||
"strings" | |||
"time" | |||
) | |||
@@ -25,7 +24,7 @@ import ( | |||
// @Param req body comm.ImgReqUploadReq true "签名上传url" | |||
// @Success 200 {string} "许可链接" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/comm/getOssUrl [get] | |||
// @Router /api/v1/comm/getOssUrl [POST] | |||
func GetOssUrl(c *gin.Context) { | |||
var args comm.ImgReqUploadReq | |||
err := c.ShouldBindJSON(&args) | |||
@@ -56,7 +55,6 @@ func GetOssUrl(c *gin.Context) { | |||
ossBucketScheme := cfgMap[enum2.AliyunOssBucketScheme] | |||
accessKeyID := cfgMap[enum2.AliyunOssAccessKeyID] | |||
accessKeySecret := cfgMap[enum2.AliyunOssAccessKeySecret] | |||
aliyunOptions := cfgMap[enum2.AliyunOptions] | |||
// 创建OSSClient实例。 | |||
client, err := oss.New(ossBucketScheme+"://"+endpoint, accessKeyID, accessKeySecret) | |||
@@ -72,12 +70,8 @@ func GetOssUrl(c *gin.Context) { | |||
return | |||
} | |||
optionsList := strings.Split(aliyunOptions, ",") | |||
var options []oss.Option | |||
for _, option := range optionsList { | |||
options = append(options, oss.ContentType(option)) | |||
options := []oss.Option{ | |||
oss.ContentType(args.ContentType), | |||
} | |||
signedURL, err := bucket.SignURL(args.FileName, oss.HTTPPut, 60*5, options...) | |||
@@ -5,7 +5,8 @@ type AccessRecordsReq struct { | |||
} | |||
type ImgReqUploadReq struct { | |||
FileName string `json:"file_name" binding:"required" example:"文件名"` | |||
FileName string `json:"file_name,required" binding:"required" example:"文件名"` | |||
ContentType string `json:"content_type,required" binding:"required" example:"image/jpeg"` | |||
} | |||
type UploadReq struct { | |||
@@ -144,6 +144,6 @@ func route(r *gin.RouterGroup) { | |||
} | |||
func rComm(r *gin.RouterGroup) { | |||
r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL | |||
r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL | |||
r.GET("/accessRecords", comm.AccessRecords) // 访问记录 | |||
} |
@@ -24,53 +24,6 @@ const docTemplate = `{ | |||
"host": "{{.Host}}", | |||
"basePath": "{{.BasePath}}", | |||
"paths": { | |||
"/api/comm/getOssUrl": { | |||
"get": { | |||
"description": "上传许可链接(获取)", | |||
"consumes": [ | |||
"application/json" | |||
], | |||
"produces": [ | |||
"application/json" | |||
], | |||
"tags": [ | |||
"对象存储" | |||
], | |||
"summary": "通用请求-对象存储-上传许可链接(获取)", | |||
"parameters": [ | |||
{ | |||
"type": "string", | |||
"description": "验证参数Bearer和token空格拼接", | |||
"name": "Authorization", | |||
"in": "header", | |||
"required": true | |||
}, | |||
{ | |||
"description": "签名上传url", | |||
"name": "req", | |||
"in": "body", | |||
"required": true, | |||
"schema": { | |||
"$ref": "#/definitions/comm.ImgReqUploadReq" | |||
} | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "许可链接", | |||
"schema": { | |||
"type": "string" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/addFriend/basalRate": { | |||
"get": { | |||
"description": "基础速率(获取)", | |||
@@ -727,6 +680,53 @@ const docTemplate = `{ | |||
} | |||
} | |||
}, | |||
"/api/v1/comm/getOssUrl": { | |||
"post": { | |||
"description": "上传许可链接(获取)", | |||
"consumes": [ | |||
"application/json" | |||
], | |||
"produces": [ | |||
"application/json" | |||
], | |||
"tags": [ | |||
"对象存储" | |||
], | |||
"summary": "通用请求-对象存储-上传许可链接(获取)", | |||
"parameters": [ | |||
{ | |||
"type": "string", | |||
"description": "验证参数Bearer和token空格拼接", | |||
"name": "Authorization", | |||
"in": "header", | |||
"required": true | |||
}, | |||
{ | |||
"description": "签名上传url", | |||
"name": "req", | |||
"in": "body", | |||
"required": true, | |||
"schema": { | |||
"$ref": "#/definitions/comm.ImgReqUploadReq" | |||
} | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "许可链接", | |||
"schema": { | |||
"type": "string" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/config": { | |||
"get": { | |||
"description": "基本配置", | |||
@@ -2361,9 +2361,14 @@ const docTemplate = `{ | |||
"comm.ImgReqUploadReq": { | |||
"type": "object", | |||
"required": [ | |||
"content_type", | |||
"file_name" | |||
], | |||
"properties": { | |||
"content_type": { | |||
"type": "string", | |||
"example": "image/jpeg" | |||
}, | |||
"file_name": { | |||
"type": "string", | |||
"example": "文件名" | |||
@@ -18,53 +18,6 @@ | |||
"host": "ddxq.izhim.com", | |||
"basePath": "/api/v1", | |||
"paths": { | |||
"/api/comm/getOssUrl": { | |||
"get": { | |||
"description": "上传许可链接(获取)", | |||
"consumes": [ | |||
"application/json" | |||
], | |||
"produces": [ | |||
"application/json" | |||
], | |||
"tags": [ | |||
"对象存储" | |||
], | |||
"summary": "通用请求-对象存储-上传许可链接(获取)", | |||
"parameters": [ | |||
{ | |||
"type": "string", | |||
"description": "验证参数Bearer和token空格拼接", | |||
"name": "Authorization", | |||
"in": "header", | |||
"required": true | |||
}, | |||
{ | |||
"description": "签名上传url", | |||
"name": "req", | |||
"in": "body", | |||
"required": true, | |||
"schema": { | |||
"$ref": "#/definitions/comm.ImgReqUploadReq" | |||
} | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "许可链接", | |||
"schema": { | |||
"type": "string" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/addFriend/basalRate": { | |||
"get": { | |||
"description": "基础速率(获取)", | |||
@@ -721,6 +674,53 @@ | |||
} | |||
} | |||
}, | |||
"/api/v1/comm/getOssUrl": { | |||
"post": { | |||
"description": "上传许可链接(获取)", | |||
"consumes": [ | |||
"application/json" | |||
], | |||
"produces": [ | |||
"application/json" | |||
], | |||
"tags": [ | |||
"对象存储" | |||
], | |||
"summary": "通用请求-对象存储-上传许可链接(获取)", | |||
"parameters": [ | |||
{ | |||
"type": "string", | |||
"description": "验证参数Bearer和token空格拼接", | |||
"name": "Authorization", | |||
"in": "header", | |||
"required": true | |||
}, | |||
{ | |||
"description": "签名上传url", | |||
"name": "req", | |||
"in": "body", | |||
"required": true, | |||
"schema": { | |||
"$ref": "#/definitions/comm.ImgReqUploadReq" | |||
} | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "许可链接", | |||
"schema": { | |||
"type": "string" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/config": { | |||
"get": { | |||
"description": "基本配置", | |||
@@ -2355,9 +2355,14 @@ | |||
"comm.ImgReqUploadReq": { | |||
"type": "object", | |||
"required": [ | |||
"content_type", | |||
"file_name" | |||
], | |||
"properties": { | |||
"content_type": { | |||
"type": "string", | |||
"example": "image/jpeg" | |||
}, | |||
"file_name": { | |||
"type": "string", | |||
"example": "文件名" | |||
@@ -20,10 +20,14 @@ definitions: | |||
type: object | |||
comm.ImgReqUploadReq: | |||
properties: | |||
content_type: | |||
example: image/jpeg | |||
type: string | |||
file_name: | |||
example: 文件名 | |||
type: string | |||
required: | |||
- content_type | |||
- file_name | |||
type: object | |||
md.AdvertisingBasic: | |||
@@ -1246,37 +1250,6 @@ info: | |||
title: 蛋蛋星球-APP客户端 | |||
version: "1.0" | |||
paths: | |||
/api/comm/getOssUrl: | |||
get: | |||
consumes: | |||
- application/json | |||
description: 上传许可链接(获取) | |||
parameters: | |||
- description: 验证参数Bearer和token空格拼接 | |||
in: header | |||
name: Authorization | |||
required: true | |||
type: string | |||
- description: 签名上传url | |||
in: body | |||
name: req | |||
required: true | |||
schema: | |||
$ref: '#/definitions/comm.ImgReqUploadReq' | |||
produces: | |||
- application/json | |||
responses: | |||
"200": | |||
description: 许可链接 | |||
schema: | |||
type: string | |||
"400": | |||
description: 具体错误 | |||
schema: | |||
$ref: '#/definitions/md.Response' | |||
summary: 通用请求-对象存储-上传许可链接(获取) | |||
tags: | |||
- 对象存储 | |||
/api/v1/addFriend/basalRate: | |||
get: | |||
consumes: | |||
@@ -1710,6 +1683,37 @@ paths: | |||
summary: 蛋蛋学院-文章-分享后调用统计数量 | |||
tags: | |||
- 蛋蛋学院 | |||
/api/v1/comm/getOssUrl: | |||
post: | |||
consumes: | |||
- application/json | |||
description: 上传许可链接(获取) | |||
parameters: | |||
- description: 验证参数Bearer和token空格拼接 | |||
in: header | |||
name: Authorization | |||
required: true | |||
type: string | |||
- description: 签名上传url | |||
in: body | |||
name: req | |||
required: true | |||
schema: | |||
$ref: '#/definitions/comm.ImgReqUploadReq' | |||
produces: | |||
- application/json | |||
responses: | |||
"200": | |||
description: 许可链接 | |||
schema: | |||
type: string | |||
"400": | |||
description: 具体错误 | |||
schema: | |||
$ref: '#/definitions/md.Response' | |||
summary: 通用请求-对象存储-上传许可链接(获取) | |||
tags: | |||
- 对象存储 | |||
/api/v1/config: | |||
get: | |||
consumes: | |||