🍃 Optimization download config

This commit is contained in:
微凉
2021-08-21 17:10:56 +08:00
parent f927c974cf
commit eefe53ff01
4 changed files with 24 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ package controllers
import (
"github.com/Xhofe/alist/alidrive"
"github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/server/models"
"github.com/Xhofe/alist/utils"
"github.com/gin-gonic/gin"
@@ -14,8 +15,12 @@ type DownReq struct {
Password string `form:"pw"`
}
// handle download request
// Down handle download request
func Down(c *gin.Context) {
if !conf.Conf.Server.Download {
c.JSON(200,MetaResponse(403,"not allowed download and preview"))
return
}
filePath := c.Param("path")[1:]
var down DownReq
if err := c.ShouldBindQuery(&down); err != nil {

View File

@@ -2,6 +2,7 @@ package controllers
import (
"github.com/Xhofe/alist/alidrive"
"github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/utils"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
@@ -13,6 +14,10 @@ type OfficePreviewReq struct {
// handle office_preview request
func OfficePreview(c *gin.Context) {
if !conf.Conf.Server.Download {
c.JSON(200,MetaResponse(403,"not allowed download and preview"))
return
}
drive := utils.GetDriveByName(c.Param("drive"))
if drive == nil {
c.JSON(200, MetaResponse(400, "drive isn't exist."))

View File

@@ -2,6 +2,7 @@ package controllers
import (
"github.com/Xhofe/alist/alidrive"
"github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/utils"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
@@ -13,6 +14,10 @@ type VideoPreviewReq struct {
// VideoPreview handle video_preview request
func VideoPreview(c *gin.Context) {
if !conf.Conf.Server.Download {
c.JSON(200,MetaResponse(403,"not allowed download and preview"))
return
}
drive := utils.GetDriveByName(c.Param("drive"))
if drive == nil {
c.JSON(200, MetaResponse(400, "drive isn't exist."))
@@ -33,6 +38,10 @@ func VideoPreview(c *gin.Context) {
}
func VideoPreviewPlayInfo(c *gin.Context) {
if !conf.Conf.Server.Download {
c.JSON(200,MetaResponse(403,"not allowed download and preview"))
return
}
drive := utils.GetDriveByName(c.Param("drive"))
if drive == nil {
c.JSON(200, MetaResponse(400, "drive isn't exist."))