aboutsummaryrefslogtreecommitdiff
path: root/go/operation/submit.go
diff options
context:
space:
mode:
authortnextday <fw2k4@163.com>2015-12-02 16:35:16 +0800
committertnextday <fw2k4@163.com>2015-12-02 16:35:16 +0800
commitd0e2475ecea97ac96ddbdc76f98a5de32e4a68ad (patch)
tree1975074bc84c01a5179edc517ffd46b3e40c0a6e /go/operation/submit.go
parent2c0a7fe75e1e3c1a0f04ab22414d3054a3095078 (diff)
downloadseaweedfs-d0e2475ecea97ac96ddbdc76f98a5de32e4a68ad.tar.xz
seaweedfs-d0e2475ecea97ac96ddbdc76f98a5de32e4a68ad.zip
`FilePart.Upload` use base name instead of full path
fix chunked file download error
Diffstat (limited to 'go/operation/submit.go')
-rw-r--r--go/operation/submit.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/go/operation/submit.go b/go/operation/submit.go
index 8af36c722..65f20cf55 100644
--- a/go/operation/submit.go
+++ b/go/operation/submit.go
@@ -116,11 +116,12 @@ func (fi FilePart) Upload(maxMB int, master string, secret security.Secret) (ret
if closer, ok := fi.Reader.(io.Closer); ok {
defer closer.Close()
}
+ baseName := path.Base(fi.FileName)
if maxMB > 0 && fi.FileSize > int64(maxMB*1024*1024) {
chunkSize := int64(maxMB * 1024 * 1024)
chunks := fi.FileSize/chunkSize + 1
cm := ChunkManifest{
- Name: fi.FileName,
+ Name: baseName,
Size: fi.FileSize,
Mime: fi.MimeType,
Chunks: make([]*ChunkInfo, 0, chunks),
@@ -128,7 +129,7 @@ func (fi FilePart) Upload(maxMB int, master string, secret security.Secret) (ret
for i := int64(0); i < chunks; i++ {
id, count, e := upload_one_chunk(
- fi.FileName+"-"+strconv.FormatInt(i+1, 10),
+ baseName+"-"+strconv.FormatInt(i+1, 10),
io.LimitReader(fi.Reader, chunkSize),
master, fi.Replication, fi.Collection, fi.Ttl,
jwt)
@@ -152,7 +153,7 @@ func (fi FilePart) Upload(maxMB int, master string, secret security.Secret) (ret
cm.DeleteChunks(master)
}
} else {
- ret, e := Upload(fileUrl, fi.FileName, fi.Reader, fi.IsGzipped, fi.MimeType, jwt)
+ ret, e := Upload(fileUrl, baseName, fi.Reader, fi.IsGzipped, fi.MimeType, jwt)
if e != nil {
return 0, e
}