Skip to content

Conversation

@antecanis8
Copy link

@antecanis8 antecanis8 commented Sep 29, 2025

还没写完

已经实现:
list
link
put
mkdir

目前存在的问题:
大文件获取到的下载链接过长 无法下载
从api获取到的分块下载地址是否能用
部分api还是旧版 是否需要都更换为v2
获取存储详情和移动文件 还未实现
目前只做了302代理的下载 本机代理未实现
新增的依赖是否可以精简

Description / 描述

小米云盘驱动😎

Motivation and Context / 背景

为什么一直没人做🧐
api参考 github.com/wangbjun/go-micloud

How Has This Been Tested? / 测试

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

目前存在的问题:
大文件获取到的下载链接过长 无法下载
从api获取到的分块下载地址是否能用
部分api还是旧版  是否需要都更换为v2
获取存储详情和移动文件  还未实现
目前只做了302代理的下载  本机代理未实现
新增的依赖是否可以精简
Copy link
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 implements a new Xiaomi Cloud Drive driver for the OpenList project. The implementation supports file listing, downloading, uploading, and folder management through Xiaomi Cloud's API.

  • Adds complete MiCloud driver with authentication, file operations, and upload/download functionality
  • Implements automatic token renewal to maintain session validity
  • Provides file streaming, folder creation, and deletion capabilities

Reviewed Changes

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

Show a summary per file
File Description
go.mod Adds gjson library dependencies for JSON parsing
drivers/micloud/util.go Core API client implementation with HTTP operations and file management
drivers/micloud/types.go Data structures and API endpoints for MiCloud integration
drivers/micloud/meta.go Driver configuration and registration setup
drivers/micloud/driver.go Main driver interface implementation with OpenList integration
drivers/all.go Registers the new MiCloud driver in the system

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

}
// 若服务端下发新 cookie,则更新
c.updateCookiesFromResponse(resp)
io.Copy(io.Discard, resp.Body)
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

The error from io.Copy is ignored, which could mask potential issues. Consider logging or handling the error appropriately.

Copilot uses AI. Check for mistakes.
return nil, 0, err
}
buf = buf[:n]
req, _ := http.NewRequest("POST", uploadURL, strings.NewReader(string(buf)))
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

Error from http.NewRequest is ignored using blank identifier. This could cause unexpected behavior if the request creation fails.

Suggested change
req, _ := http.NewRequest("POST", uploadURL, strings.NewReader(string(buf)))
req, err := http.NewRequest("POST", uploadURL, strings.NewReader(string(buf)))
if err != nil {
return nil, 0, err
}

Copilot uses AI. Check for mistakes.
return nil, 0, err
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

Error from io.ReadAll is ignored using blank identifier. This could lead to incomplete data being processed without notification.

Suggested change
body, _ := io.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, 0, fmt.Errorf("failed to read response body: %w", err)
}

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +4
// 由于json包在类型定义中没有直接使用,但可能在方法中需要,我们保留它
// 实际上json包在MiCloudClient的实现中使用了,所以保留
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

These comments are outdated and confusing since no json package is imported in this file. The comments should be removed or clarified.

Suggested change
// 由于json包在类型定义中没有直接使用,但可能在方法中需要,我们保留它
// 实际上json包在MiCloudClient的实现中使用了,所以保留

Copilot uses AI. Check for mistakes.
Comment on lines +149 to +151
// 直链下载已使用 v2 接口实现,去除 JSONP 下载方式

// GetFileDownLoadUrl 获取文件下载URL
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

This comment appears to be a placeholder or outdated note that doesn't describe the following function. It should be removed or updated to properly document the GetFileDownLoadUrl function.

Suggested change
// 直链下载已使用 v2 接口实现,去除 JSONP 下载方式
// GetFileDownLoadUrl 获取文件下载URL
// GetFileDownLoadUrl 获取指定文件的直链下载URL。
//
// 参数 fileId 为文件的唯一标识符。该方法使用 v2 接口获取文件的直链下载地址,
// 并已去除旧的 JSONP 下载方式。返回下载URL字符串和可能的错误信息。

Copilot uses AI. Check for mistakes.
return dl, nil
}

// JSONP 下载信息方法已废弃
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

This standalone comment doesn't provide context and appears to be leftover from code refactoring. It should be removed.

Suggested change
// JSONP 下载信息方法已废弃

Copilot uses AI. Check for mistakes.
}

// 上传小文件(小于4MB)
// uploadSmallFile/uploadLargeFile paths were deprecated and removed. The unified Upload handles both cases.
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

These orphaned comments don't document any actual code and appear to be leftover from refactoring. They should be removed.

Suggested change
// uploadSmallFile/uploadLargeFile paths were deprecated and removed. The unified Upload handles both cases.

Copilot uses AI. Check for mistakes.
@PIKACHUIM
Copy link
Member

什么?小米有云盘?

@ljcbaby
Copy link
Contributor

ljcbaby commented Oct 14, 2025

什么?小米有云盘?

有,云服务里的,纯云盘,没有分享之类的能力

@antecanis8
Copy link
Author

antecanis8 commented Oct 15, 2025

目前小米云盘的网页使用jsonp方式跨域获取下载地址 电脑客户端直接获取直链下载地址和分块下载地址 4MB一个块

下载地址需要接受一个meta作为校验 当要下载的文件较小时 meta可以作为get请求的参数 当要下载的文件很大时 meta会超出 get请求的 URL 长度限制 必须作为post请求的表单

对于795MB的文件 meta有34.8KB
对于113KB的文件 meta有267字节
对于22MB的文件 meta有1.13KB

总结:小文件才能使用302下载 大文件必须代理

@ljcbaby
Copy link
Contributor

ljcbaby commented Oct 16, 2025

那就直接全部使用代理吧,这样可以保证功能一致性

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.

3 participants