mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-20 15:06:36 +00:00
feat(sora): add GDrive full-cycle test endpoint (upload/download/delete)
This commit is contained in:
1 parent
3f1ca43514
commit
298f5c1baf
4 files changed
+82
-2
No files matched your search
@@ -13,13 +13,15 @@ import (
|
||||
type GDriveOAuthHandler struct {
|
||||
settingService *service.SettingService
|
||||
gdriveOAuth *service.SoraGDriveOAuthService
|
||||
gdriveStorage *service.SoraGDriveStorage
|
||||
}
|
||||
|
||||
// NewGDriveOAuthHandler 创建 GDrive OAuth Handler。
|
||||
func NewGDriveOAuthHandler(settingService *service.SettingService, gdriveOAuth *service.SoraGDriveOAuthService) *GDriveOAuthHandler {
|
||||
func NewGDriveOAuthHandler(settingService *service.SettingService, gdriveOAuth *service.SoraGDriveOAuthService, gdriveStorage *service.SoraGDriveStorage) *GDriveOAuthHandler {
|
||||
return &GDriveOAuthHandler{
|
||||
settingService: settingService,
|
||||
gdriveOAuth: gdriveOAuth,
|
||||
gdriveStorage: gdriveStorage,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,3 +129,20 @@ func (h *GDriveOAuthHandler) OAuthCallback(c *gin.Context) {
|
||||
"message": "OAuth 授权成功",
|
||||
})
|
||||
}
|
||||
|
||||
// TestGDriveStorage 测试 GDrive 存储的完整上传→下载→删除流程。
|
||||
// POST /api/v1/admin/settings/sora-storage/gdrive-test
|
||||
func (h *GDriveOAuthHandler) TestGDriveStorage(c *gin.Context) {
|
||||
if h.gdriveStorage == nil {
|
||||
response.Error(c, http.StatusInternalServerError, "GDrive storage not initialized")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.gdriveStorage.TestFullCycle(c.Request.Context())
|
||||
if err != nil {
|
||||
response.Error(c, http.StatusBadRequest, "GDrive 测试失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(c, result)
|
||||
}
|
||||
Reference in new issue
Block a user