Browse Source

ListObjects() works now

HEAD
Yang Luo 2 years ago
parent
commit
f93d3f90dd
4 changed files with 7 additions and 14 deletions
  1. +1
    -1
      casdoor/resource.go
  2. +1
    -2
      object/store_provider.go
  3. +5
    -5
      storage/storage.go
  4. +0
    -6
      util/string.go

+ 1
- 1
casdoor/resource.go 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
}



+ 1
- 2
object/store_provider.go 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



+ 5
- 5
storage/storage.go 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


+ 0
- 6
util/string.go 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)
}


Loading…
Cancel
Save