🐛 google drive upload api proxy

pull/548/head
微凉 2021-12-31 00:28:50 +08:00
parent d71ed4d775
commit 6f0959a98e
3 changed files with 7 additions and 1 deletions

View File

@ -297,6 +297,7 @@ type UploadResp struct {
// TODO unfinished
func (driver Pan123) Upload(file *model.FileStream, account *model.Account) error {
return base.ErrNotImplement
parentFile, err := driver.File(file.ParentPath, account)
if err != nil {
return err

View File

@ -359,6 +359,7 @@ func (driver Cloud189) Delete(path string, account *model.Account) error {
// Upload Error: decrypt encryptionText failed
func (driver Cloud189) Upload(file *model.FileStream, account *model.Account) error {
return base.ErrNotImplement
const DEFAULT uint64 = 10485760
var count = int64(math.Ceil(float64(file.GetSize()) / float64(DEFAULT)))
var finish uint64 = 0

View File

@ -259,9 +259,13 @@ func (driver GoogleDrive) Upload(file *model.FileStream, account *model.Account)
"parents": []string{parentFile.Id},
}
var e Error
url := "https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&supportsAllDrives=true"
if account.APIProxyUrl != "" {
url = fmt.Sprintf("%s/%s", account.APIProxyUrl, url)
}
res, err := base.NoRedirectClient.R().SetHeader("Authorization", "Bearer "+account.AccessToken).
SetError(&e).SetBody(data).
Post("https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&supportsAllDrives=true")
Post(url)
if err != nil {
return err
}