diff --git a/controllers/resource.go b/controllers/resource.go index e974bf7c..72c50016 100644 --- a/controllers/resource.go +++ b/controllers/resource.go @@ -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) } diff --git a/object/resource.go b/object/resource.go index fae6f8df..ed498d0f 100644 --- a/object/resource.go +++ b/object/resource.go @@ -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 { diff --git a/web/src/ResourceListPage.js b/web/src/ResourceListPage.js index cedf73bd..a9b27c37 100644 --- a/web/src/ResourceListPage.js +++ b/web/src/ResourceListPage.js @@ -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',