|
@@ -22,7 +22,7 @@ type UploadController struct {
|
|
|
// @Description 文件上传
|
|
|
// @Tags 工具
|
|
|
// @Success 200 {object} response.Response{data=string,id=string,msg=string} "{"code": 200, "data": [...]}"
|
|
|
-// @Router /api/captcha [get]
|
|
|
+// @Router /api/upload [get]
|
|
|
func (e UploadController) FilesUpload(c *gin.Context) {
|
|
|
err := e.MakeContext(c).Errors
|
|
|
if err != nil {
|
|
@@ -63,3 +63,44 @@ func (e UploadController) FilesUpload(c *gin.Context) {
|
|
|
"msg": "success",
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+// ApkUpload 文件上传
|
|
|
+// @Summary 文件上传
|
|
|
+// @Description 文件上传
|
|
|
+// @Tags 工具
|
|
|
+// @Success 200 {object} response.Response{data=string,id=string,msg=string} "{"code": 200, "data": [...]}"
|
|
|
+// @Router /api/apk-upload [get]
|
|
|
+func (e UploadController) ApkUpload(c *gin.Context) {
|
|
|
+ err := e.MakeContext(c).Errors
|
|
|
+ if err != nil {
|
|
|
+ e.Error(500, err, "服务初始化失败!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理文件上传逻辑
|
|
|
+ file, err := c.FormFile("file")
|
|
|
+ uploadFileName := file.Filename // 获取文件名
|
|
|
+ fileType := filepath.Ext(uploadFileName) // 获取文件类型(扩展名)
|
|
|
+ if err != nil {
|
|
|
+ c.JSON(500, gin.H{"error": err.Error()})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if fileType != ".apk" {
|
|
|
+ c.JSON(500, gin.H{"code": 200,
|
|
|
+ "data": conf.ExtConfig.Apk.Path + "/" + uploadFileName,
|
|
|
+ "msg": "success"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ filePath := conf.ExtConfig.Apk.Path + "/" + uploadFileName
|
|
|
+ err = c.SaveUploadedFile(file, filePath)
|
|
|
+ if err != nil {
|
|
|
+ c.JSON(500, gin.H{"error": err.Error()})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ e.Custom(gin.H{
|
|
|
+ "code": 200,
|
|
|
+ "data": conf.ExtConfig.Apk.Path + "/" + uploadFileName,
|
|
|
+ "msg": "success",
|
|
|
+ })
|
|
|
+}
|