drive: Remove --drive-alternate-export in favor of exportLinks

Google engineer confirms that the new official API should works properly:
https://issuetracker.google.com/issues/36761333#comment8
This commit is contained in:
themylogin 2020-08-13 00:42:28 +02:00 committed by Nick Craig-Wood
parent 23b2c58018
commit 57c10babfe
2 changed files with 4 additions and 46 deletions

View file

@ -17,7 +17,6 @@ import (
"log" "log"
"mime" "mime"
"net/http" "net/http"
"net/url"
"path" "path"
"sort" "sort"
"strconv" "strconv"
@ -70,7 +69,7 @@ const (
// 1<<18 is the minimum size supported by the Google uploader, and there is no maximum. // 1<<18 is the minimum size supported by the Google uploader, and there is no maximum.
minChunkSize = 256 * fs.KibiByte minChunkSize = 256 * fs.KibiByte
defaultChunkSize = 8 * fs.MebiByte defaultChunkSize = 8 * fs.MebiByte
partialFields = "id,name,size,md5Checksum,trashed,explicitlyTrashed,modifiedTime,createdTime,mimeType,parents,webViewLink,shortcutDetails" partialFields = "id,name,size,md5Checksum,trashed,explicitlyTrashed,modifiedTime,createdTime,mimeType,parents,webViewLink,shortcutDetails,exportLinks"
listRGrouping = 50 // number of IDs to search at once when using ListR listRGrouping = 50 // number of IDs to search at once when using ListR
listRInputBuffer = 1000 // size of input buffer when using ListR listRInputBuffer = 1000 // size of input buffer when using ListR
) )
@ -354,17 +353,8 @@ date is used.`,
}, { }, {
Name: "alternate_export", Name: "alternate_export",
Default: false, Default: false,
Help: `Use alternate export URLs for google documents export., Help: "Deprecated: no longer needed",
Hide: fs.OptionHideBoth,
If this option is set this instructs rclone to use an alternate set of
export URLs for drive documents. Users have reported that the
official export URLs can't export large documents, whereas these
unofficial ones can.
See rclone issue [#2243](https://github.com/rclone/rclone/issues/2243) for background,
[this google drive issue](https://issuetracker.google.com/issues/36761333) and
[this helpful post](https://www.labnol.org/internet/direct-links-for-google-drive/28356/).`,
Advanced: true,
}, { }, {
Name: "upload_cutoff", Name: "upload_cutoff",
Default: defaultChunkSize, Default: defaultChunkSize,
@ -527,7 +517,6 @@ type Options struct {
UseSharedDate bool `config:"use_shared_date"` UseSharedDate bool `config:"use_shared_date"`
ListChunk int64 `config:"list_chunk"` ListChunk int64 `config:"list_chunk"`
Impersonate string `config:"impersonate"` Impersonate string `config:"impersonate"`
AlternateExport bool `config:"alternate_export"`
UploadCutoff fs.SizeSuffix `config:"upload_cutoff"` UploadCutoff fs.SizeSuffix `config:"upload_cutoff"`
ChunkSize fs.SizeSuffix `config:"chunk_size"` ChunkSize fs.SizeSuffix `config:"chunk_size"`
AcknowledgeAbuse bool `config:"acknowledge_abuse"` AcknowledgeAbuse bool `config:"acknowledge_abuse"`
@ -1253,20 +1242,7 @@ func (f *Fs) newDocumentObject(remote string, info *drive.File, extension, expor
if err != nil { if err != nil {
return nil, err return nil, err
} }
id := actualID(info.Id) url := info.ExportLinks[mediaType]
url := fmt.Sprintf("%sfiles/%s/export?mimeType=%s", f.svc.BasePath, id, url.QueryEscape(mediaType))
if f.opt.AlternateExport {
switch info.MimeType {
case "application/vnd.google-apps.drawing":
url = fmt.Sprintf("https://docs.google.com/drawings/d/%s/export/%s", id, extension[1:])
case "application/vnd.google-apps.document":
url = fmt.Sprintf("https://docs.google.com/document/d/%s/export?format=%s", id, extension[1:])
case "application/vnd.google-apps.spreadsheet":
url = fmt.Sprintf("https://docs.google.com/spreadsheets/d/%s/export?format=%s", id, extension[1:])
case "application/vnd.google-apps.presentation":
url = fmt.Sprintf("https://docs.google.com/presentation/d/%s/export/%s", id, extension[1:])
}
}
baseObject := f.newBaseObject(remote+extension, info) baseObject := f.newBaseObject(remote+extension, info)
baseObject.bytes = -1 baseObject.bytes = -1
baseObject.mimeType = exportMimeType baseObject.mimeType = exportMimeType

View file

@ -813,24 +813,6 @@ Impersonate this user when using a service account.
- Type: string - Type: string
- Default: "" - Default: ""
#### --drive-alternate-export
Use alternate export URLs for google documents export.,
If this option is set this instructs rclone to use an alternate set of
export URLs for drive documents. Users have reported that the
official export URLs can't export large documents, whereas these
unofficial ones can.
See rclone issue [#2243](https://github.com/rclone/rclone/issues/2243) for background,
[this google drive issue](https://issuetracker.google.com/issues/36761333) and
[this helpful post](https://www.labnol.org/internet/direct-links-for-google-drive/28356/).
- Config: alternate_export
- Env Var: RCLONE_DRIVE_ALTERNATE_EXPORT
- Type: bool
- Default: false
#### --drive-upload-cutoff #### --drive-upload-cutoff
Cutoff for switching to chunked upload Cutoff for switching to chunked upload