mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-02-24 23:13:53 +08:00
added bbolt file download
This commit is contained in:
parent
859e35c1a4
commit
7b3220732e
2 changed files with 22 additions and 2 deletions
|
@ -1,9 +1,29 @@
|
|||
package routes
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/divyam234/teldrive/database"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
func AddRoutes(router *gin.Engine) {
|
||||
api := router.Group("/api")
|
||||
api.GET("/bbolt", Authmiddleware, func(c *gin.Context) {
|
||||
err := database.BoltDB.View(func(tx *bbolt.Tx) error {
|
||||
c.Writer.Header().Set("Content-Type", "application/octet-stream")
|
||||
c.Writer.Header().Set("Content-Disposition", `attachment; filename="teldrive.db"`)
|
||||
c.Writer.Header().Set("Content-Length", strconv.Itoa(int(tx.Size())))
|
||||
_, err := tx.WriteTo(c.Writer)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
http.Error(c.Writer, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
})
|
||||
addAuthRoutes(api)
|
||||
addFileRoutes(api)
|
||||
addUploadRoutes(api)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e69660100478be62c9e4ff9b5a3d2b4a53811d3e
|
||||
Subproject commit a2d12d64157b72ef3d7daa359db0f6a07917d5ec
|
Loading…
Reference in a new issue