Skip to content

feat(drivers): add teldrive#1116

Merged
xrgzs merged 11 commits intoOpenListTeam:mainfrom
TwoOnefour:my_repo
Aug 24, 2025
Merged

feat(drivers): add teldrive#1116
xrgzs merged 11 commits intoOpenListTeam:mainfrom
TwoOnefour:my_repo

Conversation

@TwoOnefour
Copy link
Copy Markdown
Contributor

@TwoOnefour TwoOnefour commented Aug 20, 2025

https://github.com/tgdrive/teldrive

Official api docs

实现:

  • copy
  • move
  • link (302 share and local proxy)
  • chunked uploads
  • rename

未实现:

  • openlist扫码登陆
  • refresh token

OpenListTeam/OpenList-Docs#155

@TwoOnefour
Copy link
Copy Markdown
Contributor Author

这个302好像写的有点小问题,我可能还得改改😨

@xrgzs
Copy link
Copy Markdown
Member

xrgzs commented Aug 20, 2025

@TwoOnefour 文档提交的时候需要注意一下,这个非官方维护。

@TwoOnefour
Copy link
Copy Markdown
Contributor Author

@TwoOnefour 文档提交的时候需要注意一下,这个非官方维护。

ok

https://github.com/tgdrive/teldrive

[Official api docs](https://teldrive-docs.pages.dev/docs/api)

implement:
* copy
* move
* link (302 share and local proxy)
* chunk upload
* rename

Not yet implement:
- login (scan qrcode or auth by password)
- refresh token
@TwoOnefour
Copy link
Copy Markdown
Contributor Author

TwoOnefour commented Aug 20, 2025

这个302好像写的有点小问题,我可能还得改改😨

改好了,明天我再把文档搬一下

@TwoOnefour
Copy link
Copy Markdown
Contributor Author

TwoOnefour commented Aug 20, 2025 via email

@xrgzs
Copy link
Copy Markdown
Member

xrgzs commented Aug 21, 2025

第一个地方因为我最开始Link方法想实现直接返回后端url+cookie的model.Link,但前端得到的raw_url就完全是不通过openlist流量的url(比如在使用本地代理下载时,直接会跳转驱动后端的地址127.0.0.1而不是openlist本身url),在我选定了本地代理+web代理后才会变成正常走openlist流量url,所以才加了这一段,我调了很久还是不是很能理解为什么会这样😢

可以去看一下 OpenList-Proxy 的实现,可以通过 /api/fs/link 这个接口将 cookie 等头部暴露出来

// Link return real link, just for proxy program, it may contain cookie, so just allowed for admin
func Link(c *gin.Context) {
var req MkdirOrLinkReq
if err := c.ShouldBind(&req); err != nil {
common.ErrorResp(c, err, 400)
return
}
//user := c.Request.Context().Value(conf.UserKey).(*model.User)
//rawPath := stdpath.Join(user.BasePath, req.Path)
// why need not join base_path? because it's always the full path
rawPath := req.Path
storage, err := fs.GetStorage(rawPath, &fs.GetStoragesArgs{})
if err != nil {
common.ErrorResp(c, err, 500)
return
}
if storage.Config().NoLinkURL || storage.Config().OnlyLinkMFile {
common.SuccessResp(c, model.Link{
URL: fmt.Sprintf("%s/p%s?d&sign=%s",
common.GetApiUrl(c),
utils.EncodePath(rawPath, true),
sign.Sign(rawPath)),
})
return
}
link, _, err := fs.Link(c.Request.Context(), rawPath, model.LinkArgs{IP: c.ClientIP(), Header: c.Request.Header, Redirect: true})
if err != nil {
common.ErrorResp(c, err, 500)
return
}
defer link.Close()
common.SuccessResp(c, link)
}

看了下 文档 ,这个驱动下载非分享文件貌似必须要带 Cookie,如果是这样,那就不支持 302

xrgzs

This comment was marked as outdated.

@xrgzs xrgzs requested a review from Copilot August 23, 2025 20:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the Teldrive driver to the OpenList project, implementing integration with the Teldrive API for file storage operations. The implementation includes file operations like copy, move, link generation, chunked uploads, and rename functionality.

  • Add new Teldrive driver with full file operation support including chunked uploads
  • Implement both single and multi-part upload strategies with concurrent processing
  • Add copy/move operations with worker pool for handling directory recursion

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
drivers/teldrive/driver.go Main driver implementation with core file operations (list, link, move, rename, etc.)
drivers/teldrive/upload.go Upload functionality with chunked and concurrent upload support
drivers/teldrive/copy.go Copy operations with worker pool for handling directories and files
drivers/teldrive/util.go Utility functions for API requests, file operations, and share link creation
drivers/teldrive/types.go Type definitions for API responses and internal data structures
drivers/teldrive/meta.go Driver metadata and configuration structure
drivers/all.go Register the new Teldrive driver in the global driver list

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@xrgzs
Copy link
Copy Markdown
Member

xrgzs commented Aug 23, 2025

这个302好像写的有点小问题,我可能还得改改😨

改好了,明天我再把文档搬一下

@TwoOnefour 测试一下上传有没有问题,文档改好就可以合并了

@ILoveScratch2 ILoveScratch2 changed the title feat(Teldrive): Add Teldrive support feat(drivers): add teldrive Aug 24, 2025
@TwoOnefour
Copy link
Copy Markdown
Contributor Author

这个302好像写的有点小问题,我可能还得改改😨

改好了,明天我再把文档搬一下

@TwoOnefour 测试一下上传有没有问题,文档改好就可以合并了

刚测了单文件和分块上传都没问题,我搓个文档

@TwoOnefour
Copy link
Copy Markdown
Contributor Author

那个分块应该是10,我改一下

@xrgzs xrgzs merged commit b0dbbeb into OpenListTeam:main Aug 24, 2025
12 checks passed
@akang943578
Copy link
Copy Markdown
Contributor

请问这个在docker版已经有了吗,我pull了最新镜像,添加storage里还是没有找到teldrive

fsca8 pushed a commit to fsca8/OpenList that referenced this pull request Oct 4, 2025
https://github.com/tgdrive/teldrive

https://teldrive-docs.pages.dev/docs/api

实现:
* copy
* move
* link (302 share and local proxy)
* chunked uploads
* rename

未实现:
- openlist扫码登陆
- refresh token

OpenListTeam/OpenList-Docs#155


* feat(Teldrive): Add driver Teldrive

* fix(teldrive): force webproxy and memory optimized

* chore(teldrive): go fmt

* chore(teldrive): remove TODO

* chore(teldrive): organize code

* feat(teldrive): add UseShareLink option and support 302

* fix(teldrive): standardize API path construction

* fix(teldrive): trim trailing slash from Address in Init method

* chore(teldrive): update help text for UseShareLink field in Addition struct

* fix(teldrive): set 10 MiB as default chunk size

---------

Co-authored-by: MadDogOwner <xiaoran@xrgzs.top>
Co-authored-by: ILoveScratch <ilovescratch@foxmail.com>
@totza2010
Copy link
Copy Markdown
Contributor

It seems like there needs to be a function for random chunk names during the upload process.
https://teldrive-docs.pages.dev/docs/guides/rclone

@xrgzs
Copy link
Copy Markdown
Member

xrgzs commented Jan 25, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants