ソースを参照

upload file manage

link 3 年 前
コミット
07e96511cd
2 ファイル変更5 行追加13 行削除
  1. 1 1
      UI
  2. 4 12
      route/v1/file.go

+ 1 - 1
UI

@@ -1 +1 @@
-Subproject commit ebaf4b2fc6b4cf416fff197629dc0f8f02cf3b31
+Subproject commit 30aac33948d96c4c302438f98a435fc51953702a

+ 4 - 12
route/v1/file.go

@@ -293,6 +293,7 @@ func GetFileUpload(c *gin.Context) {
 	relative := c.Query("relativePath")
 	relative := c.Query("relativePath")
 	fileName := c.Query("filename")
 	fileName := c.Query("filename")
 	chunkNumber := c.Query("chunkNumber")
 	chunkNumber := c.Query("chunkNumber")
+	totalChunks, _ := strconv.Atoi(c.DefaultQuery("totalChunks", "0"))
 	path := c.Query("path")
 	path := c.Query("path")
 	dirPath := ""
 	dirPath := ""
 	if fileName != relative {
 	if fileName != relative {
@@ -300,12 +301,7 @@ func GetFileUpload(c *gin.Context) {
 		file.MkDir(path + "/" + dirPath)
 		file.MkDir(path + "/" + dirPath)
 	}
 	}
 	hash := file.GetHashByContent([]byte(fileName))
 	hash := file.GetHashByContent([]byte(fileName))
-	tempDir := path + "/"
-	if len(dirPath) > 0 {
-		tempDir += dirPath + "/" + hash + "/" + chunkNumber
-	} else {
-		tempDir += hash + "/" + chunkNumber
-	}
+	tempDir := "/casaOS/temp/" + hash + strconv.Itoa(totalChunks) + "/" + chunkNumber
 	if !file.CheckNotExist(tempDir) {
 	if !file.CheckNotExist(tempDir) {
 		c.JSON(200, model.Result{Success: 200, Message: oasis_err2.GetMsg(oasis_err2.FILE_ALREADY_EXISTS)})
 		c.JSON(200, model.Result{Success: 200, Message: oasis_err2.GetMsg(oasis_err2.FILE_ALREADY_EXISTS)})
 		return
 		return
@@ -343,12 +339,8 @@ func PostFileUpload(c *gin.Context) {
 		dirPath = strings.TrimSuffix(relative, fileName)
 		dirPath = strings.TrimSuffix(relative, fileName)
 		file.MkDir(path + "/" + dirPath)
 		file.MkDir(path + "/" + dirPath)
 	}
 	}
-	tempDir := path + "/"
-	if len(dirPath) > 0 {
-		tempDir += dirPath + "/" + hash
-	} else {
-		tempDir += hash
-	}
+	tempDir := "/casaOS/temp/" + hash + strconv.Itoa(totalChunks)
+
 	path += "/" + relative
 	path += "/" + relative
 
 
 	if !file.CheckNotExist(tempDir + "/" + chunkNumber) {
 	if !file.CheckNotExist(tempDir + "/" + chunkNumber) {