fix: support 2GB base attachment uploads#441
Conversation
📝 WalkthroughWalkthroughThis PR extends base record attachment upload functionality to support files up to 2GB by integrating multipart upload capabilities. For files exceeding 20MB, the code now uses a multipart upload sequence ( Changes
Sequence DiagramsequenceDiagram
participant Client
participant BaseRecordUpload
participant UploadHelper as Upload Helper
participant DriveAPI as Drive API
Client->>BaseRecordUpload: Upload attachment (fileSize, filePath)
BaseRecordUpload->>BaseRecordUpload: Validate fileSize ≤ 2GB
alt fileSize ≤ 20MB
BaseRecordUpload->>UploadHelper: UploadDriveMediaAll()
UploadHelper->>DriveAPI: POST /upload_all
DriveAPI-->>UploadHelper: fileToken
else fileSize > 20MB
BaseRecordUpload->>UploadHelper: UploadDriveMediaMultipart()
UploadHelper->>DriveAPI: POST /upload_prepare
DriveAPI-->>UploadHelper: uploadId
loop for each part
UploadHelper->>DriveAPI: POST /upload_part
DriveAPI-->>UploadHelper: partToken
end
UploadHelper->>DriveAPI: POST /upload_finish
DriveAPI-->>UploadHelper: fileToken
end
UploadHelper-->>BaseRecordUpload: fileToken
BaseRecordUpload->>Client: Updated record with attachment
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@aae49d5d64bae61e16661945547480af3c8820cb🧩 Skill updatenpx skills add larksuite/cli#codex/base-attachment-multipart-upload -y -g |
Co-authored-by: kongenpei <kongenpei@users.noreply.github.com>
Summary
Support
base +record-upload-attachmentfor larger files by switching to Drive multipart upload above 20MB and keeping validation/output explicit for AI-agent use.Changes
Test Plan
make unit-test)lark-cli base +record-upload-attachmentcommand works as expected (multipart upload succeeds for20MB + 1 byteand exact2GB;2GB + 1 bytefails fast withexceeds 2GB limit)go mod tidygo run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/mainRelated Issues
Summary by CodeRabbit
Release Notes
New Features
Documentation