Backend: Insert shared file into files_share table #225

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-04-01 18:17:29 +02:00
parent d9d476b9d5
commit 1adc144ac2
2 changed files with 4 additions and 5 deletions

View file

@ -2,7 +2,6 @@ package api
import (
"net/http"
"os"
"strconv"
"github.com/gin-gonic/gin"
@ -147,12 +146,10 @@ func ShareWithAccount(router *gin.RouterGroup, conf *config.Config) {
}
for _, file := range files {
srcFileName := conf.OriginalsPath() + string(os.PathSeparator) + file.FileName
dstFileName := dst + "/" + file.ShareFileName()
if err := w.Upload(srcFileName, dstFileName); err != nil {
log.Errorf("upload failed: %s", err.Error())
}
fileShare := entity.NewFileShare(file.ID, m.ID, dstFileName)
fileShare.FirstOrCreate(conf.Db())
}
c.JSON(http.StatusOK, files)

View file

@ -34,6 +34,8 @@ func NewFileShare(fileID, accountID uint, remoteName string) *FileShare {
FileID: fileID,
AccountID: accountID,
RemoteName: remoteName,
Status: "new",
Error: "",
}
return result