Use objectKey as resource name.

This commit is contained in:
Yang Luo 2021-09-04 15:02:11 +08:00
parent b3eec024b8
commit 5d98cc6ac5
3 changed files with 13 additions and 6 deletions

View File

@ -102,7 +102,7 @@ func (c *ApiController) DeleteResource() {
return
}
err = object.DeleteFile(provider, resource.ObjectKey)
err = object.DeleteFile(provider, resource.Name)
if err != nil {
c.ResponseError(err.Error())
return
@ -155,16 +155,16 @@ func (c *ApiController) UploadResource() {
fileSize := int(header.Size)
resource := &object.Resource{
Owner: owner,
Name: filename,
Name: objectKey,
CreatedTime: util.GetCurrentTime(),
Provider: provider.Name,
Tag: tag,
Parent: parent,
FileName: filename,
FileType: fileType,
FileFormat: fileFormat,
FileSize: fileSize,
Url: fileUrl,
ObjectKey: objectKey,
}
object.AddOrUpdateResource(resource)
@ -179,5 +179,5 @@ func (c *ApiController) UploadResource() {
object.UpdateApplication(applicationId, app)
}
c.ResponseOk(fileUrl)
c.ResponseOk(fileUrl, objectKey)
}

View File

@ -16,9 +16,9 @@ package object
import (
"fmt"
"xorm.io/core"
"github.com/casbin/casdoor/util"
"xorm.io/core"
)
type Resource struct {
@ -29,11 +29,11 @@ type Resource struct {
Provider string `xorm:"varchar(100)" json:"provider"`
Tag string `xorm:"varchar(100)" json:"tag"`
Parent string `xorm:"varchar(100)" json:"parent"`
FileName string `xorm:"varchar(100)" json:"fileName"`
FileType string `xorm:"varchar(100)" json:"fileType"`
FileFormat string `xorm:"varchar(100)" json:"fileFormat"`
FileSize int `json:"fileSize"`
Url string `xorm:"varchar(100)" json:"url"`
ObjectKey string `xorm:"varchar(100)" json:"objectKey"`
}
func GetResources(owner string) []*Resource {

View File

@ -135,6 +135,13 @@ class ResourceListPage extends React.Component {
width: '80px',
sorter: (a, b) => a.parent.localeCompare(b.parent),
},
{
title: i18next.t("resource:File name"),
dataIndex: 'fileName',
key: 'fileName',
width: '120px',
sorter: (a, b) => a.fileName.localeCompare(b.fileName),
},
{
title: i18next.t("resource:File type"),
dataIndex: 'fileType',