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

View File

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