-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drive: FilesCreateCall.Media does not support file size #452
Labels
api: drive
Issues related to the Drive API API.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Comments
tbpg
changed the title
FilesCreateCall.Media does not support file size
drive: FilesCreateCall.Media does not support file size
Feb 18, 2020
tbpg
added
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
and removed
triage me
I really want to be triaged.
labels
Feb 18, 2020
Try this. f, _ := os.Open(*File)
info, _ := f.Stat()
total := FileSizeFormat(info.Size())
upf := srv.Files.Create(&drive.File{Name: info.Name()}).Media(f).ProgressUpdater(func(current, _ int64) {
fmt.Printf("Uploaded %s/%s @ %.2f%%\r", FileSizeFormat(current), total, float64(current*100)/float64(info.Size()))
})
if _, err := upf.Do(); err == nil {
log.Println("Done.")
} else {
log.Println(err.Error())
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
api: drive
Issues related to the Drive API API.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
In the v3 API, using
Files.Create(...)
withMedia
support does not allow for specifying total file size. As a result, theProgressUpdater
function supplied always receives atotal
value of 0.Using
ReusableMedia
does support total size, but the doc states:The only way to calculate upload progress is to use the deprecated
ReusableMedia
support. The internally createdMediaInfo
does not expose thesize
value, and the only way to set it is viaNewInfoFromReusableMedia
, which is called by theFilesCreateCall.ReusableMedia
method.FilesCreateCall.Media
usesNewInfoFromMedia
, and I don't see a way to specify size.The text was updated successfully, but these errors were encountered: