This function downloads a file from Google Drive. Native Google file types, such as Google Docs, Google Sheets, and Google Slides, must be exported to a conventional local file type. This can be specified:
implicitly via the file extension of
not at all, i.e. rely on the built-in default
To see what export file types are even possible, see the Drive API documentation
or the result of
drive_about()$exportFormats. The returned dribble
drive_download( file, path = NULL, type = NULL, overwrite = FALSE, verbose = deprecated() )
Character. Path for output file. If absent, the default file name is the file's name on Google Drive and the default location is working directory, possibly with an added file extension.
Character. Only consulted if
A logical scalar. If local
This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use
An object of class
dribble, a tibble with one row per file.
Download files, in the Drive API documentation.
# Upload a csv file into a Google Sheet file <- drive_upload( drive_example("chicken.csv"), type = "spreadsheet" ) #> Local file: #> • /home/runner/work/_temp/Library/googledrive/extdata/chicken.csv #> Uploaded into Drive file: #> • chicken <id: 1aa03eyCZG5MnEBitFb9v3F3pZQaI1LSoHWeu5QAJufs> #> With MIME type: #> • application/vnd.google-apps.spreadsheet # Download Sheet as csv, explicit type downloaded_file <- drive_download(file, type = "csv") #> File downloaded: #> • chicken <id: 1aa03eyCZG5MnEBitFb9v3F3pZQaI1LSoHWeu5QAJufs> #> Saved locally as: #> • chicken.csv # See local path to new file downloaded_file$local_path #>  "chicken.csv" # Download as csv, type implicit in file extension drive_download(file, path = "my_csv_file.csv") #> File downloaded: #> • chicken <id: 1aa03eyCZG5MnEBitFb9v3F3pZQaI1LSoHWeu5QAJufs> #> Saved locally as: #> • my_csv_file.csv # Download with default name and type (xlsx) drive_download(file) #> File downloaded: #> • chicken <id: 1aa03eyCZG5MnEBitFb9v3F3pZQaI1LSoHWeu5QAJufs> #> Saved locally as: #> • chicken.xlsx # Clean up unlink(c("chicken.csv", "chicken.xlsx", "my_csv_file.csv")) drive_rm(file) #> File deleted: #> • chicken <id: 1aa03eyCZG5MnEBitFb9v3F3pZQaI1LSoHWeu5QAJufs>