forked from saltbo/zpan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:don't allow move the folder into itself #4 (saltbo#26) * fix:don't allow move the folder into itself #4 * fix: action building failed * refactor: splitting logic as FileMove and FolderMove Co-authored-by: lu.longshan <luls0728@zsmarter.com> chore: update the front code to resolve #4 fix: resolve the issue #5 feat: support s3 and storage saltbo#10 chore: update the front code to resolve saltbo#11 feat: support search to resolve the issue saltbo#13 chore: update the assets to fix create folder test: add some ut for the disk
- Loading branch information
1 parent
2898dac
commit b804fd6
Showing
16 changed files
with
205 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
FROM moreu:latest | ||
FROM debian:10 | ||
|
||
RUN echo \ | ||
deb http://mirrors.aliyun.com/debian buster main \ | ||
deb http://mirrors.aliyun.com/debian buster-updates main \ | ||
deb http://mirrors.aliyun.com/debian-security buster/updates main \ | ||
> /etc/apt/sources.list | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y ca-certificates telnet procps curl | ||
|
||
ENV APP_HOME /zpan | ||
WORKDIR $APP_HOME | ||
|
||
RUN curl -sSf https://dl.saltbo.cn/install.sh | sh -s zpan | ||
|
||
CMD ["zpan", "server"] | ||
CMD ["zpan", "server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package disk | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/service/s3" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// default config | ||
var dc = Config{ | ||
Name: "s3", | ||
Bucket: "test-bucket", | ||
Endpoint: "s3.ap-northeast-1.amazonaws.com", | ||
AccessKey: "test-ak", | ||
AccessSecret: "test-sk", | ||
} | ||
|
||
var key = "1001/test.txt" | ||
|
||
func checkSignedURLStr(t *testing.T, us, customHost string) *url.URL { | ||
host := fmt.Sprintf("%s.%s", dc.Bucket, dc.Endpoint) | ||
if customHost != "" { | ||
host = strings.TrimPrefix(customHost, "http://") | ||
} | ||
u, err := url.Parse(us) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "/"+key, u.Path) | ||
assert.Equal(t, host, u.Host) | ||
assert.Contains(t, u.RawQuery, dc.AccessKey) | ||
assert.NotContains(t, u.RawQuery, dc.AccessSecret) | ||
return u | ||
} | ||
|
||
func testSignedGetUrl(t *testing.T, conf Config) { | ||
disk, err := New(conf) | ||
assert.NoError(t, err) | ||
|
||
us, headers, err := disk.SignedPutURL(key, "text/plain", false) | ||
assert.NoError(t, err) | ||
checkSignedURLStr(t, us, conf.CustomHost) | ||
|
||
assert.Equal(t, s3.ObjectCannedACLAuthenticatedRead, headers.Get("x-amz-acl")) | ||
assert.Equal(t, "text/plain", headers.Get("content-type")) | ||
} | ||
|
||
func TestSignedPutURL(t *testing.T) { | ||
testSignedGetUrl(t, dc) | ||
} | ||
|
||
func TestSignedPutURLWithCustomHost(t *testing.T) { | ||
conf := dc | ||
conf.CustomHost = "http://dl.zpan.com" | ||
testSignedGetUrl(t, conf) | ||
} | ||
|
||
func TestSignedGetURL(t *testing.T) { | ||
disk, err := New(dc) | ||
assert.NoError(t, err) | ||
|
||
filename := "test2.txt" | ||
us, err := disk.SignedGetURL(key, filename) | ||
assert.NoError(t, err) | ||
u := checkSignedURLStr(t, us, "") | ||
assert.Equal(t, u.Query().Get("response-content-disposition"), fmt.Sprintf(`attachment;filename="%s"`, urlEncode(filename))) | ||
} | ||
|
||
func TestPublicURL(t *testing.T) { | ||
disk, err := New(dc) | ||
assert.NoError(t, err) | ||
|
||
us := disk.PublicURL(key) | ||
u, err := url.Parse(us) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "/"+key, u.Path) | ||
assert.Equal(t, fmt.Sprintf("%s.%s", dc.Bucket, dc.Endpoint), u.Host) | ||
} | ||
|
||
func TestNotSupportedProvider(t *testing.T) { | ||
conf := dc | ||
conf.Name = "test-provider" | ||
_, err := New(conf) | ||
assert.Error(t, err) | ||
} | ||
|
||
func TestNew4Storage(t *testing.T) { | ||
conf := dc | ||
conf.Name = "storage" | ||
_, err := New(conf) | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.