|
@ -15,7 +15,6 @@ import ( |
|
|
"github.com/chrislusf/seaweedfs/weed/util" |
|
|
"github.com/chrislusf/seaweedfs/weed/util" |
|
|
"io" |
|
|
"io" |
|
|
"net/http" |
|
|
"net/http" |
|
|
"path" |
|
|
|
|
|
"strconv" |
|
|
"strconv" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
@ -165,7 +164,6 @@ func uploadFileAsOne(filerAddress, filerGrpcAddress string, urlFolder string, f |
|
|
// upload the file content
|
|
|
// upload the file content
|
|
|
fileName := filepath.Base(f.Name()) |
|
|
fileName := filepath.Base(f.Name()) |
|
|
mimeType := detectMimeType(f) |
|
|
mimeType := detectMimeType(f) |
|
|
isGzipped := isGzipped(fileName) |
|
|
|
|
|
|
|
|
|
|
|
var chunks []*filer_pb.FileChunk |
|
|
var chunks []*filer_pb.FileChunk |
|
|
|
|
|
|
|
@ -184,7 +182,7 @@ func uploadFileAsOne(filerAddress, filerGrpcAddress string, urlFolder string, f |
|
|
|
|
|
|
|
|
targetUrl := "http://" + assignResult.Url + "/" + assignResult.Fid |
|
|
targetUrl := "http://" + assignResult.Url + "/" + assignResult.Fid |
|
|
|
|
|
|
|
|
uploadResult, err := operation.Upload(targetUrl, fileName, f, isGzipped, mimeType, nil, "") |
|
|
|
|
|
|
|
|
uploadResult, err := operation.Upload(targetUrl, fileName, f, false, mimeType, nil, "") |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Printf("upload data %v to %s: %v\n", fileName, targetUrl, err) |
|
|
fmt.Printf("upload data %v to %s: %v\n", fileName, targetUrl, err) |
|
|
return false |
|
|
return false |
|
@ -318,10 +316,6 @@ func uploadFileInChunks(filerAddress, filerGrpcAddress string, urlFolder string, |
|
|
return true |
|
|
return true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func isGzipped(filename string) bool { |
|
|
|
|
|
return strings.ToLower(path.Ext(filename)) == ".gz" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func detectMimeType(f *os.File) string { |
|
|
func detectMimeType(f *os.File) string { |
|
|
head := make([]byte, 512) |
|
|
head := make([]byte, 512) |
|
|
f.Seek(0, 0) |
|
|
f.Seek(0, 0) |
|
|