SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
a little refactoring
Chris Lu2d7dea1a091e
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.goindex 3b8193cd1d..5a878e675d 100644--- a/weed/command/filer_copy.go+++ b/weed/command/filer_copy.go@@ -149,17 +149,9 @@ func doEachCopy(fileOrDir string, host string, path string) bool {func uploadFileAsOne(filerUrl string, urlPath string, assignResult *operation.AssignResult, f *os.File, fi os.FileInfo) bool {// upload the file content- ext := strings.ToLower(path.Ext(f.Name()))- head := make([]byte, 512)- f.Seek(0, 0)- n, err := f.Read(head)- if err != nil {- fmt.Printf("read head of %v: %v\n", f.Name(), err)- return false- }- f.Seek(0, 0)- mimeType := http.DetectContentType(head[:n])- isGzipped := ext == ".gz"++ mimeType := detectMimeType(f)+ isGzipped := isGzipped(f.Name())targetUrl := "http://" + assignResult.Url + "/" + assignResult.Fid@@ -186,3 +178,20 @@ func uploadFileAsOne(filerUrl string, urlPath string, assignResult *operation.Asfunc uploadFileInChunks(filerUrl string, path string, assignResult *operation.AssignResult, f *os.File, chunkCount int) bool {return false}++func isGzipped(filename string) bool {+ return strings.ToLower(path.Ext(filename)) == ".gz"+}++func detectMimeType(f *os.File) string {+ head := make([]byte, 512)+ f.Seek(0, 0)+ n, err := f.Read(head)+ if err != nil {+ fmt.Printf("read head of %v: %v\n", f.Name(), err)+ return "application/octet-stream"+ }+ f.Seek(0, 0)+ mimeType := http.DetectContentType(head[:n])+ return mimeType+}