fuelly api complete

This commit is contained in:
Akhil Gupta
2021-06-26 09:48:29 +05:30
parent 2bd8481670
commit 5f96345828
6 changed files with 207 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package controllers
import (
"io/ioutil"
"net/http"
"os"
@@ -116,6 +117,18 @@ func getAttachmentFile(c *gin.Context) {
}
}
func getFileBytes(c *gin.Context, fileVariable string) ([]byte, error) {
if fileVariable == "" {
fileVariable = "file"
}
formFile, err := c.FormFile(fileVariable)
if err != nil {
return nil, err
}
openedFile, _ := formFile.Open()
return ioutil.ReadAll(openedFile)
}
func saveUploadedFile(c *gin.Context, fileVariable string) (*db.Attachment, error) {
if fileVariable == "" {
fileVariable = "file"