ListObjects() works now

This commit is contained in:
Yang Luo 2023-07-30 22:05:04 +08:00
parent 23a2de182f
commit f93d3f90dd
4 changed files with 7 additions and 14 deletions

View File

@ -24,7 +24,7 @@ import (
func ListResources(provider string, prefix string) ([]*casdoorsdk.Resource, error) {
casdoorOrganization := beego.AppConfig.String("casdoorOrganization")
casdoorApplication := beego.AppConfig.String("casdoorApplication")
res, err := casdoorsdk.GetResources(casdoorOrganization, casdoorApplication, "provider", provider, "Casibase", "")
res, err := casdoorsdk.GetResources(casdoorOrganization, casdoorApplication, "provider", provider, "Direct", prefix)
return res, err
}

View File

@ -17,7 +17,6 @@ package object
import (
"fmt"
"strings"
"time"
"github.com/casbin/casibase/storage"
)
@ -109,7 +108,7 @@ func (store *Store) Populate() error {
}
for _, object := range sortedObjects {
lastModifiedTime := object.LastModified.Local().Format(time.RFC3339)
lastModifiedTime := object.LastModified
isLeaf := isObjectLeaf(object)
size := object.Size

View File

@ -19,7 +19,6 @@ import (
"fmt"
"io"
"net/http"
"time"
"github.com/astaxie/beego"
"github.com/casbin/casibase/casdoor"
@ -29,8 +28,9 @@ import (
type Object struct {
Key string
LastModified *time.Time
LastModified string
Size int64
Url string
}
func ListObjects(provider string, prefix string) ([]*Object, error) {
@ -41,11 +41,11 @@ func ListObjects(provider string, prefix string) ([]*Object, error) {
res := []*Object{}
for _, resource := range resources {
created, _ := time.Parse(time.RFC3339, resource.CreatedTime)
res = append(res, &Object{
Key: util.GetNameFromIdNoCheck(resource.Name),
LastModified: &created,
Key: resource.Name,
LastModified: resource.CreatedTime,
Size: int64(resource.FileSize),
Url: resource.Url,
})
}
return res, nil

View File

@ -93,12 +93,6 @@ func GetOwnerAndNameFromId3New(id string) (string, string, string) {
return tokens[0], tokens[1], tokens[2]
}
func GetNameFromIdNoCheck(id string) string {
tokens := strings.Split(id, "/")
return tokens[len(tokens)-1]
}
func GetIdFromOwnerAndName(owner string, name string) string {
return fmt.Sprintf("%s/%s", owner, name)
}