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

View File

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

View File

@@ -135,6 +135,13 @@ class ResourceListPage extends React.Component {
width: '80px', width: '80px',
sorter: (a, b) => a.parent.localeCompare(b.parent), 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"), title: i18next.t("resource:File type"),
dataIndex: 'fileType', dataIndex: 'fileType',