add mime, use simple insert and update filer store API

1. add mime type to file in filer
2. purge old chunks if overwrite during insert
This commit is contained in:
Chris Lu
2018-05-30 20:24:57 -07:00
parent 26e7cd8c75
commit 0301504184
20 changed files with 149 additions and 132 deletions

View File

@@ -174,7 +174,7 @@ func uploadFileAsOne(filerUrl string, urlFolder string, f *os.File, fi os.FileIn
fmt.Printf("uploaded %s to %s\n", f.Name(), targetUrl)
if err = filer_operation.RegisterFile(filerUrl, filepath.Join(urlFolder, f.Name()), assignResult.Fid, fi.Size(),
os.Getuid(), os.Getgid(), copy.secret); err != nil {
mimeType, os.Getuid(), os.Getgid(), copy.secret); err != nil {
fmt.Printf("Failed to register file %s on %s: %v\n", f.Name(), filerUrl, err)
return false
}
@@ -185,6 +185,8 @@ func uploadFileAsOne(filerUrl string, urlFolder string, f *os.File, fi os.FileIn
func uploadFileInChunks(filerUrl string, urlFolder string, f *os.File, fi os.FileInfo, chunkCount int, chunkSize int64) bool {
mimeType := detectMimeType(f)
var chunks []*filer_pb.FileChunk
for i := int64(0); i < int64(chunkCount); i++ {
@@ -235,6 +237,7 @@ func uploadFileInChunks(filerUrl string, urlFolder string, f *os.File, fi os.Fil
Uid: uint32(os.Getuid()),
FileSize: uint64(fi.Size()),
FileMode: uint32(fi.Mode()),
Mime: mimeType,
},
Chunks: chunks,
},