Add more args to UploadResource().

This commit is contained in:
Gucheng Wang 2021-11-21 16:21:35 +08:00
parent 95600414d9
commit 44b59d866a
2 changed files with 8 additions and 1 deletions

View File

@ -103,6 +103,8 @@ func (c *ApiController) UploadResource() {
tag := c.Input().Get("tag") tag := c.Input().Get("tag")
parent := c.Input().Get("parent") parent := c.Input().Get("parent")
fullFilePath := c.Input().Get("fullFilePath") fullFilePath := c.Input().Get("fullFilePath")
createdTime := c.Input().Get("createdTime")
description := c.Input().Get("description")
file, header, err := c.GetFile("file") file, header, err := c.GetFile("file")
if err != nil { if err != nil {
@ -144,12 +146,15 @@ func (c *ApiController) UploadResource() {
return return
} }
if createdTime == "" {
createdTime = util.GetCurrentTime()
}
fileFormat := filepath.Ext(fullFilePath) fileFormat := filepath.Ext(fullFilePath)
fileSize := int(header.Size) fileSize := int(header.Size)
resource := &object.Resource{ resource := &object.Resource{
Owner: owner, Owner: owner,
Name: objectKey, Name: objectKey,
CreatedTime: util.GetCurrentTime(), CreatedTime: createdTime,
User: username, User: username,
Provider: provider.Name, Provider: provider.Name,
Application: application, Application: application,
@ -160,6 +165,7 @@ func (c *ApiController) UploadResource() {
FileFormat: fileFormat, FileFormat: fileFormat,
FileSize: fileSize, FileSize: fileSize,
Url: fileUrl, Url: fileUrl,
Description: description,
} }
object.AddOrUpdateResource(resource) object.AddOrUpdateResource(resource)

View File

@ -36,6 +36,7 @@ type Resource struct {
FileFormat string `xorm:"varchar(100)" json:"fileFormat"` FileFormat string `xorm:"varchar(100)" json:"fileFormat"`
FileSize int `json:"fileSize"` FileSize int `json:"fileSize"`
Url string `xorm:"varchar(1000)" json:"url"` Url string `xorm:"varchar(1000)" json:"url"`
Description string `xorm:"varchar(1000)" json:"description"`
} }
func GetResourceCount(owner string, user string) int { func GetResourceCount(owner string, user string) int {