mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-01-09 16:49:51 +08:00
resume file uploads
This commit is contained in:
parent
92b0dc1efc
commit
3e6f19e58f
2 changed files with 25 additions and 9 deletions
|
@ -1,5 +1,8 @@
|
||||||
<h1 align="center"> Fast Telegram Drive</h1>
|
<h1 align="center"> Fast Telegram Drive</h1>
|
||||||
|
|
||||||
|
[![Discord](https://img.shields.io/discord/1142377485737148479?label=discord&logo=discord&style=flat-square&logoColor=white)](https://discord.gg/hfTUKGU2C6)
|
||||||
|
|
||||||
|
|
||||||
<details open="open">
|
<details open="open">
|
||||||
<summary>Table of Contents</summary>
|
<summary>Table of Contents</summary>
|
||||||
<ol>
|
<ol>
|
||||||
|
|
|
@ -61,6 +61,14 @@ func (us *UploadService) UploadFile(c *gin.Context) (*schemas.UploadPartOut, *ty
|
||||||
|
|
||||||
uploadId := c.Param("id")
|
uploadId := c.Param("id")
|
||||||
|
|
||||||
|
var uploadPart []models.Upload
|
||||||
|
|
||||||
|
us.Db.Model(&models.Upload{}).Where("upload_id = ?", uploadId).Where("part_no = ?", uploadQuery.PartNo).Find(&uploadPart)
|
||||||
|
|
||||||
|
if len(uploadPart) == 1 {
|
||||||
|
out := mapSchema(&uploadPart[0])
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
config := utils.GetConfig()
|
config := utils.GetConfig()
|
||||||
|
|
||||||
var tgClient *utils.Client
|
var tgClient *utils.Client
|
||||||
|
@ -138,15 +146,20 @@ func (us *UploadService) UploadFile(c *gin.Context) (*schemas.UploadPartOut, *ty
|
||||||
return nil, &types.AppError{Error: errors.New("failed to upload part"), Code: http.StatusInternalServerError}
|
return nil, &types.AppError{Error: errors.New("failed to upload part"), Code: http.StatusInternalServerError}
|
||||||
}
|
}
|
||||||
|
|
||||||
out := &schemas.UploadPartOut{
|
out := mapSchema(partUpload)
|
||||||
ID: partUpload.ID,
|
|
||||||
Name: partUpload.Name,
|
|
||||||
PartId: partUpload.PartId,
|
|
||||||
ChannelID: partUpload.ChannelID,
|
|
||||||
PartNo: partUpload.PartNo,
|
|
||||||
TotalParts: partUpload.TotalParts,
|
|
||||||
Size: partUpload.Size,
|
|
||||||
}
|
|
||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mapSchema(in *models.Upload) *schemas.UploadPartOut {
|
||||||
|
out := &schemas.UploadPartOut{
|
||||||
|
ID: in.ID,
|
||||||
|
Name: in.Name,
|
||||||
|
PartId: in.PartId,
|
||||||
|
ChannelID: in.ChannelID,
|
||||||
|
PartNo: in.PartNo,
|
||||||
|
TotalParts: in.TotalParts,
|
||||||
|
Size: in.Size,
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue