diff --git a/object/store.go b/object/store.go
index 6b31da6..ba2aae2 100644
--- a/object/store.go
+++ b/object/store.go
@@ -27,6 +27,7 @@ type File struct {
Size int64 `json:"size"`
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
IsLeaf bool `json:"isLeaf"`
+ Url string `xorm:"varchar(255)" json:"url"`
Children []*File `xorm:"varchar(1000)" json:"children"`
ChildrenMap map[string]*File `xorm:"-" json:"-"`
diff --git a/object/store_provider.go b/object/store_provider.go
index aa1d092..d0130f2 100644
--- a/object/store_provider.go
+++ b/object/store_provider.go
@@ -21,7 +21,7 @@ import (
"github.com/casbin/casibase/storage"
)
-func (store *Store) createPathIfNotExisted(tokens []string, size int64, lastModifiedTime string, isLeaf bool) {
+func (store *Store) createPathIfNotExisted(tokens []string, size int64, url string, lastModifiedTime string, isLeaf bool) {
currentFile := store.FileTree
for i, token := range tokens {
if currentFile.Children == nil {
@@ -47,6 +47,7 @@ func (store *Store) createPathIfNotExisted(tokens []string, size int64, lastModi
Key: key,
Title: token,
IsLeaf: isLeafTmp,
+ Url: url,
Children: []*File{},
ChildrenMap: map[string]*File{},
}
@@ -90,6 +91,7 @@ func (store *Store) Populate() error {
Title: store.DisplayName,
CreatedTime: store.CreatedTime,
IsLeaf: false,
+ Url: "",
Children: []*File{},
ChildrenMap: map[string]*File{},
}
@@ -111,9 +113,10 @@ func (store *Store) Populate() error {
lastModifiedTime := object.LastModified
isLeaf := isObjectLeaf(object)
size := object.Size
+ url := object.Url
tokens := strings.Split(strings.Trim(object.Key, "/"), "/")
- store.createPathIfNotExisted(tokens, size, lastModifiedTime, isLeaf)
+ store.createPathIfNotExisted(tokens, size, url, lastModifiedTime, isLeaf)
// fmt.Printf("%s, %d, %v\n", object.Key, object.Size, object.LastModified)
}
diff --git a/storage/storage.go b/storage/storage.go
index 6cd731a..6ae25ae 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -20,9 +20,7 @@ import (
"io"
"net/http"
- "github.com/astaxie/beego"
"github.com/casbin/casibase/casdoor"
- "github.com/casbin/casibase/util"
"github.com/casdoor/casdoor-go-sdk/casdoorsdk"
)
@@ -66,8 +64,7 @@ func GetObject(provider string, key string) (io.ReadCloser, error) {
}
func PutObject(provider string, key string, fileBuffer *bytes.Buffer) error {
- _, _, err := casdoorsdk.UploadResource("Casibase", "Casibase", "Casibase",
- fmt.Sprintf("/casibase/%s", key), fileBuffer.Bytes())
+ _, _, err := casdoorsdk.UploadResource("Casibase", "", "", fmt.Sprintf("Direct/%s/%s", provider, key), fileBuffer.Bytes())
if err != nil {
return err
}
@@ -75,8 +72,7 @@ func PutObject(provider string, key string, fileBuffer *bytes.Buffer) error {
}
func DeleteObject(provider string, key string) error {
- casdoorOrganization := beego.AppConfig.String("casdoorOrganization")
- _, err := casdoorsdk.DeleteResource(util.GetIdFromOwnerAndName(casdoorOrganization, fmt.Sprintf("/casibase/%s", key)))
+ _, err := casdoorsdk.DeleteResource(fmt.Sprintf("Direct/%s/%s", provider, key))
if err != nil {
return err
}
diff --git a/web/src/FileTable.js b/web/src/FileTable.js
index 5153a83..661c2c2 100644
--- a/web/src/FileTable.js
+++ b/web/src/FileTable.js
@@ -207,8 +207,7 @@ class FileTable extends React.Component {
{text}
} style={{marginLeft: "20px", marginRight: "10px"}} type="primary" size="small" onClick={() => {
files.filter(file => file.isLeaf).forEach((file, index) => {
- const url = `${this.props.store.domain}/${file.key}`;
- Setting.openLink(url);
+ Setting.openLink(file.url);
});
}}>{i18next.t("store:Download")}
} size="small" onClick={(e) => {
Setting.showMessage("success", "Successfully downloaded");
- const url = `${store.domain}/${file.key}`;
- Setting.openLink(url);
+ Setting.openLink(file.url);
e.stopPropagation();
}} />
@@ -671,7 +670,7 @@ class FileTree extends React.Component {
}
const ext = Setting.getExtFromPath(path);
- const url = `${store.domain}/${path}`;
+ const url = this.state.selectedFile.url;
const app = this.getCacheApp(filename);
if (app !== "") {