ListObjects() works now
This commit is contained in:
parent
23a2de182f
commit
f93d3f90dd
|
@ -24,7 +24,7 @@ import (
|
||||||
func ListResources(provider string, prefix string) ([]*casdoorsdk.Resource, error) {
|
func ListResources(provider string, prefix string) ([]*casdoorsdk.Resource, error) {
|
||||||
casdoorOrganization := beego.AppConfig.String("casdoorOrganization")
|
casdoorOrganization := beego.AppConfig.String("casdoorOrganization")
|
||||||
casdoorApplication := beego.AppConfig.String("casdoorApplication")
|
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
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ package object
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/casbin/casibase/storage"
|
"github.com/casbin/casibase/storage"
|
||||||
)
|
)
|
||||||
|
@ -109,7 +108,7 @@ func (store *Store) Populate() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, object := range sortedObjects {
|
for _, object := range sortedObjects {
|
||||||
lastModifiedTime := object.LastModified.Local().Format(time.RFC3339)
|
lastModifiedTime := object.LastModified
|
||||||
isLeaf := isObjectLeaf(object)
|
isLeaf := isObjectLeaf(object)
|
||||||
size := object.Size
|
size := object.Size
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/casbin/casibase/casdoor"
|
"github.com/casbin/casibase/casdoor"
|
||||||
|
@ -29,8 +28,9 @@ import (
|
||||||
|
|
||||||
type Object struct {
|
type Object struct {
|
||||||
Key string
|
Key string
|
||||||
LastModified *time.Time
|
LastModified string
|
||||||
Size int64
|
Size int64
|
||||||
|
Url string
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListObjects(provider string, prefix string) ([]*Object, error) {
|
func ListObjects(provider string, prefix string) ([]*Object, error) {
|
||||||
|
@ -41,11 +41,11 @@ func ListObjects(provider string, prefix string) ([]*Object, error) {
|
||||||
|
|
||||||
res := []*Object{}
|
res := []*Object{}
|
||||||
for _, resource := range resources {
|
for _, resource := range resources {
|
||||||
created, _ := time.Parse(time.RFC3339, resource.CreatedTime)
|
|
||||||
res = append(res, &Object{
|
res = append(res, &Object{
|
||||||
Key: util.GetNameFromIdNoCheck(resource.Name),
|
Key: resource.Name,
|
||||||
LastModified: &created,
|
LastModified: resource.CreatedTime,
|
||||||
Size: int64(resource.FileSize),
|
Size: int64(resource.FileSize),
|
||||||
|
Url: resource.Url,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
|
|
|
@ -93,12 +93,6 @@ func GetOwnerAndNameFromId3New(id string) (string, string, string) {
|
||||||
return tokens[0], tokens[1], tokens[2]
|
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 {
|
func GetIdFromOwnerAndName(owner string, name string) string {
|
||||||
return fmt.Sprintf("%s/%s", owner, name)
|
return fmt.Sprintf("%s/%s", owner, name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue