41 lines
910 B
Go
41 lines
910 B
Go
package handlers
|
|
|
|
import "github.com/labstack/echo/v4"
|
|
|
|
type FileInfo struct {
|
|
FileName string `json:"fileName"`
|
|
FileSize int64 `json:"fileSize"`
|
|
FileType string `json:"fileType"`
|
|
}
|
|
|
|
func RootHandler(c echo.Context) error {
|
|
return c.JSON(200, map[string]string{
|
|
"status": "😺",
|
|
"docs": "https://illfillthisoutlater.com",
|
|
})
|
|
}
|
|
|
|
// UploadHandler e.POST("/upload")
|
|
func UploadHandler(c echo.Context) error {
|
|
file, err := c.FormFile("file")
|
|
if err != nil {
|
|
c.Logger().Errorf("Error retrieving file from request: %v", err)
|
|
}
|
|
|
|
if file == nil {
|
|
c.Logger().Error("No file provided in the request")
|
|
}
|
|
|
|
fileName := file.Filename
|
|
fileSize := file.Size
|
|
fileType := file.Header.Get("Content-Type")
|
|
|
|
c.Logger().Infof("Received file: %s, Size: %d bytes, Type: %s", fileName, fileSize, fileType)
|
|
|
|
return c.JSON(200, FileInfo{
|
|
FileName: fileName,
|
|
FileSize: fileSize,
|
|
FileType: fileType,
|
|
})
|
|
}
|