mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-25 17:42:25 +01:00
30 lines
629 B
Go
30 lines
629 B
Go
package routes
|
|
|
|
import (
|
|
"crawlab/utils"
|
|
"github.com/gin-gonic/gin"
|
|
"io/ioutil"
|
|
"net/http"
|
|
)
|
|
|
|
// @Summary Get file
|
|
// @Description Get file
|
|
// @Tags file
|
|
// @Produce json
|
|
// @Param Authorization header string true "Authorization token"
|
|
// @Success 200 json string Response
|
|
// @Failure 400 json string Response
|
|
// @Router /file [get]
|
|
func GetFile(c *gin.Context) {
|
|
path := c.Query("path")
|
|
fileBytes, err := ioutil.ReadFile(path)
|
|
if err != nil {
|
|
HandleError(http.StatusInternalServerError, c, err)
|
|
}
|
|
c.JSON(http.StatusOK, Response{
|
|
Status: "ok",
|
|
Message: "success",
|
|
Data: utils.BytesToString(fileBytes),
|
|
})
|
|
}
|