feat(drivers): add teldrive#1116
Conversation
|
这个302好像写的有点小问题,我可能还得改改😨 |
|
@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
改好了,明天我再把文档搬一下 |
|
第一个地方因为我最开始Link方法想实现直接返回后端url+cookie的model.Link,但前端得到的raw_url就完全是不通过openlist流量的url(比如在使用本地代理下载时,直接会跳转驱动后端的地址127.0.0.1而不是openlist本身url),在我选定了本地代理+web代理后才会变成正常走openlist流量url,所以才加了这一段,我调了很久还是不是很能理解为什么会这样😢
后面的内存我再想想怎么改
@xrgzs commented on this pull request.
In drivers/teldrive/driver.go :
+ if d.WebdavPolicy == "native_proxy" {
+ d.WebProxy = true
+ } else {
+ d.WebProxy = false
+ }
⬇️ Suggested change
- if d.WebdavPolicy == "native_proxy" {
- d.WebProxy = true
- } else {
- d.WebProxy = false
- }
In drivers/teldrive/driver.go :
+func (d *Teldrive) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
+ if d.WebdavPolicy != "native_proxy" {
+ var address string
+ if d.WebdavPolicy == "use_proxy_url" {
+ address = d.DownProxyURL
+ } else {
+ address = d.Address
+ }
+ if shareObj, err := d.getShareFileById(file.GetID()); err == nil && shareObj != nil {
+ return &model.Link{
+ URL: address + fmt.Sprintf("/api/shares/%s/files/%s/%s", shareObj.Id, file.GetID(), file.GetName()),
+ }, nil
+ }
+ if err := d.createShareFile(file.GetID()); err != nil {
+ return nil, err
+ }
+ shareObj, err := d.getShareFileById(file.GetID())
+ if err != nil {
+ return nil, err
+ }
+ return &model.Link{
+ URL: address + fmt.Sprintf("/api/shares/%s/files/%s/%s", shareObj.Id, file.GetID(), file.GetName()),
+ }, nil
+ }
+ return &model.Link{
+ URL: d.Address + "/api/files/" + file.GetID() + "/" + file.GetName(),
+ Header: http.Header{
+ "Cookie": {d.Cookie},
+ },
+ }, nil
+}
这里的 DownProxyURL 是指 OpenList-Proxy 的地址,不应该在驱动内判断。如果有需求填写第三方的下载代理地址,最好新增一个配置项,比如 download_cdn 之类的。
In drivers/teldrive/util.go :
+ byteData := make([]byte, chunkSize)
+ n, err := io.ReadFull(file, byteData)
上传的内存占用可以优化一下,参考 #554 和 #1001 ,避免全部读到内存。
In drivers/teldrive/util.go :
+ client := resty.New().SetTimeout(0)
+
+ ctx := context.Background()
+
+ req := client.R().
+ SetContext(ctx)
改用 net/http 上传分片,避免全部读到内存。
—
Reply to this email directly, view it on GitHub , or unsubscribe .
You are receiving this because you were mentioned. Message ID: <OpenListTeam/OpenList/pull/1116/review/3137765904 @ github . com>
|
可以去看一下 OpenList-Proxy 的实现,可以通过 OpenList/server/handles/fsmanage.go Lines 373 to 405 in 6499374 看了下 文档 ,这个驱动下载非分享文件貌似必须要带 Cookie,如果是这样,那就不支持 302 |
There was a problem hiding this comment.
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.
@TwoOnefour 测试一下上传有没有问题,文档改好就可以合并了 |
刚测了单文件和分块上传都没问题,我搓个文档 |
|
那个分块应该是10,我改一下 |
|
请问这个在docker版已经有了吗,我pull了最新镜像,添加storage里还是没有找到teldrive |
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>
|
It seems like there needs to be a function for random chunk names during the upload process. |
Issues or PR are welcome. Reference: |
https://github.com/tgdrive/teldrive
Official api docs
实现:
未实现:
OpenListTeam/OpenList-Docs#155