Merge pull request #50 from fossyy/staging
Correct file size mismatch during download
This commit is contained in:
@ -32,18 +32,20 @@ func GET(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
w.Header().Set("Content-Disposition", "attachment; filename="+file.Name)
|
w.Header().Set("Content-Disposition", "attachment; filename="+file.Name)
|
||||||
w.Header().Set("Content-Type", "application/octet-stream")
|
w.Header().Set("Content-Type", "application/octet-stream")
|
||||||
for i := 0; i <= int(file.TotalChunk); i++ {
|
for i := 0; i <= int(file.TotalChunk)-1; i++ {
|
||||||
chunkPath := filepath.Join(saveFolder, file.Name, fmt.Sprintf("chunk_%d", i))
|
chunkPath := filepath.Join(saveFolder, file.Name, fmt.Sprintf("chunk_%d", i))
|
||||||
|
|
||||||
chunkFile, err := os.Open(chunkPath)
|
chunkFile, err := os.Open(chunkPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, fmt.Sprintf("Error opening chunk: %v", err), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("Error opening chunk: %v", err), http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = io.Copy(w, chunkFile)
|
_, err = io.Copy(w, chunkFile)
|
||||||
chunkFile.Close()
|
chunkFile.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, fmt.Sprintf("Error writing chunk: %v", err), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("Error writing chunk: %v", err), http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user