mirror of https://github.com/Xhofe/alist
🐛 google drive upload api proxy
parent
d71ed4d775
commit
6f0959a98e
|
@ -297,6 +297,7 @@ type UploadResp struct {
|
||||||
|
|
||||||
// TODO unfinished
|
// TODO unfinished
|
||||||
func (driver Pan123) Upload(file *model.FileStream, account *model.Account) error {
|
func (driver Pan123) Upload(file *model.FileStream, account *model.Account) error {
|
||||||
|
return base.ErrNotImplement
|
||||||
parentFile, err := driver.File(file.ParentPath, account)
|
parentFile, err := driver.File(file.ParentPath, account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -359,6 +359,7 @@ func (driver Cloud189) Delete(path string, account *model.Account) error {
|
||||||
|
|
||||||
// Upload Error: decrypt encryptionText failed
|
// Upload Error: decrypt encryptionText failed
|
||||||
func (driver Cloud189) Upload(file *model.FileStream, account *model.Account) error {
|
func (driver Cloud189) Upload(file *model.FileStream, account *model.Account) error {
|
||||||
|
return base.ErrNotImplement
|
||||||
const DEFAULT uint64 = 10485760
|
const DEFAULT uint64 = 10485760
|
||||||
var count = int64(math.Ceil(float64(file.GetSize()) / float64(DEFAULT)))
|
var count = int64(math.Ceil(float64(file.GetSize()) / float64(DEFAULT)))
|
||||||
var finish uint64 = 0
|
var finish uint64 = 0
|
||||||
|
|
|
@ -259,9 +259,13 @@ func (driver GoogleDrive) Upload(file *model.FileStream, account *model.Account)
|
||||||
"parents": []string{parentFile.Id},
|
"parents": []string{parentFile.Id},
|
||||||
}
|
}
|
||||||
var e Error
|
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).
|
res, err := base.NoRedirectClient.R().SetHeader("Authorization", "Bearer "+account.AccessToken).
|
||||||
SetError(&e).SetBody(data).
|
SetError(&e).SetBody(data).
|
||||||
Post("https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&supportsAllDrives=true")
|
Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue