Closed gorkang closed 1 year ago
I think the problem is how you are specifying the Google Drive location path
. Note the docs here:
Path to existing directory on Google Drive to store pins. Can be given as an actual path like
"path/to/folder"
(character), a file id or URL marked withgoogledrive::as_id()
, or agoogledrive::dribble
.
Can you use your URL to make a "dribble" or in googledrive::as_id()
?
To check out a working example, see how I specify my folder:
library(pins)
board <- board_gdrive("pins-testing")
#> ! Using an auto-discovered, cached token.
#> To suppress this message, modify your code or options to clearly consent to
#> the use of a cached token.
#> See gargle's "Non-interactive auth" vignette for more details:
#> <https://gargle.r-lib.org/articles/non-interactive-auth.html>
#> ℹ The googledrive package is using a cached token for 'julia.silge@gmail.com'.
board |> pin_list()
#> character(0)
path <- fs::path_temp("some-letters.txt")
readr::write_lines(sample(LETTERS, size = 20), path)
pin_upload(board, paths = path, name = "really-great-letters")
#> Creating new version '20230901T202058Z-56115'
board |> pin_list()
#> [1] "really-great-letters"
Created on 2023-09-01 with reprex v2.0.2
Thanks for the quick answer Julia!
With googledrive::as_dribble(drive_link)
or googledrive::as_id(drive_link)
I get the same error. The containing folders get created, but the file and metadata is never uploaded.
DRIBBLE = googledrive::as_dribble(drive_link)
gdrive_board = pins::board_gdrive(DRIBBLE)
gdrive_board |> pins::pin_upload(paths = "~/Downloads/999.zip", name = "Dribble_pin")
#> Error in if (is.null(name) && !has_slash(path) && drive_path_exists(append_slash(path))) { :
#> missing value where TRUE/FALSE needed
#> In addition: Warning message:
#> Unknown or uninitialised column: `path`.
ID = googledrive::as_id(drive_link)
gdrive_board = pins::board_gdrive(ID)
gdrive_board |> pins::pin_upload(paths = "~/Downloads/999.zip", name = "Id_pin")
#> Error in if (is.null(name) && !has_slash(path) && drive_path_exists(append_slash(path))) { :
#> missing value where TRUE/FALSE needed
#> In addition: Warning message:
#> Unknown or uninitialised column: `path`.
Also, when using your example (I created the pins-testing
folder first), R gets stuck, giving no feedback for a long time. I stopped it after more than 5 minutes. the containing folders are created but the file and metadata never is uploaded.
I also tried adapting your example and uploading a file with a normalizePath(), just in case. Nothing worked. I attach my session info in case helps debug this.
library(pins)
board <- board_gdrive("pins-testing")
#> ! Using an auto-discovered, cached token.
#> To suppress this message, modify your code or options to clearly consent to
#> the use of a cached token.
#> See gargle's "Non-interactive auth" vignette for more details:
#> <https://gargle.r-lib.org/articles/non-interactive-auth.html>
#> ℹ The googledrive package is using a cached token for 'gorkang@gmail.com'.
board |> pin_list()
#> [1] "really-great-letters" "really-great-letters2"
> pin_upload(board, paths = normalizePath("~/Downloads/ASD/chart.csv"), name = "really-great-letters3)
Creating new version '20230902T065741Z-afc30'
#> Nothing happens for a loong time
Created on 2023-09-02 with reprex v2.0.2
Thanks!
So those items "really-great-letters"
and "really-great-letters2"
are folders that got created but the pin contents were never uploaded?
If you have a local path
where your file is and a board
object that has authenticated, what happens when you do this (with a fake version setup)?
googledrive::drive_upload(
path,
fs::path(board$dribble$path, "20230405T060708Z-xxxxx", fs::path_file(path))
)
Yes, exactly, the folders are created but the pin contents (files) are not uploaded.
Uploading a file using your code also get's stuck. No errors, no feedback.
The only way I got it to work was by using a Dribble to the desired folder in the path
argument.
file_to_upload <- fs::path_temp("some-letters.txt")
readr::write_lines(sample(LETTERS, size = 20), file_to_upload)
DRIBBLE = googledrive::as_dribble("https://drive.google.com/drive/folders/1rZyqHbpVJ0ZPoOxXtwYGexQ-FegEXGtN")
#> ! Using an auto-discovered, cached token.
#> To suppress this message, modify your code or options to clearly consent to
#> the use of a cached token.
#> See gargle's "Non-interactive auth" vignette for more details:
#> <https://gargle.r-lib.org/articles/non-interactive-auth.html>
#> ℹ The googledrive package is using a cached token for 'gorkang@gmail.com'.
googledrive::drive_upload(
media = file_to_upload,
path = DRIBBLE,
name = fs::path_file(file_to_upload)
)
#> Local file:
#> • '/tmp/RtmpeklPCr/some-letters.txt'
#> Uploaded into Drive file:
#> • 'some-letters.txt' <id: 1QXSWb1lkf6iOWRewEstOfusn3RA4hGti>
#> With MIME type:
#> • 'text/plain'
It seems that using an actual folder path in the path
argument makes googledrive hang. It reminds me of this. I used httr::with_verbose()
to see what was going on, and I got an infinite string of things similar to:
-> GET /drive/v3/files?orderBy=recency%20desc&q=%28trashed%20%3D%20false%29%20and%20%28mimeType%20%3D%20%27application%2Fvnd.google-apps.folder%27%29&supportsAllDrives=TRUE&fields=nextPageToken%2C%2A&pageToken=~%21%21~AI9FV7SiIp4h6I262pbJBy9UAIFkIovD-ZgICvNpU5Nl-GdSlPSczGzYKT5v3OMvRPTdaPojhkPEJ0LPXTSktN0hMd9e4EWWiqr3fvbZprBxoV8DrbFMIApO6kRCyXJJXVG2ODo32O1WFEjvTLw76gQjLetnNs_XI5FeLBQmXllK6dESoWgy1CjAZu6VHSjcAcuc2m75u20n-cP6RwC1zr4MuFjrxOobmDUP8nhcmsH5eat434GLQrquWBwrFrL0foaMgF5wsh8eOrtzPXpW_d2g4wopMzWhCv7eJmCct0BXGv140FJfQo32SLm-ZdG8_o2Ox7jDTSBj9gigmRs1B1jo0Cnm1JfsYw%3D%3D HTTP/2 -> Host: www.googleapis.com -> user-agent: googledrive/2.1.1 (GPN:RStudio; ) gargle/1.5.2 httr/1.4.7 -> accept-encoding: deflate, gzip, br, zstd -> accept: application/json, text/xml, application/xml, / -> authorization: Bearer [EDITED] -> <- HTTP/2 200 <- vary: Origin, X-Origin <- date: Sat, 02 Sep 2023 20:15:04 GMT <- expires: Mon, 01 Jan 1990 00:00:00 GMT <- pragma: no-cache <- cache-control: no-cache, no-store, max-age=0, must-revalidate <- content-type: application/json; charset=UTF-8 <- content-encoding: gzip <- server: ESF <- content-length: 10454 <- x-xss-protection: 0 <- x-frame-options: SAMEORIGIN <- x-content-type-options: nosniff <- alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 Created on 2023-09-02 with reprex v2.0.2
Hmmmm, this is definitely not something I have experienced.
Can you use that working dribble as the first argument to board_gdrive()
and write a pin that way?
I created a pull request that seems to solve the issue.
The fix is very simple, just use a dribble for the path argument of googledrive::drive_upload()
.
According to the old googledrive issue mentioned above, in Google Drives with a lot of files and folders (I have > 1TB), it is important to be as specific as possible.
For whatever reason, using the full path to the file (fs::path(board$dribble$path, version_dir, "data.txt")
) in the path
argument is not enough, but using a dribble for the path, and then the name
argument for the file name, works fine.
Thank you so much for the PR @gorkang! 🙌
Closed in #780
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
Hi there. I am trying to use a Shared Google Drive folder to create pin boards to upload and download files.
If I do that with a local folder with
board_folder()
, everything works fine. But I can't makeboard_gdrive()
work with a shared Google Drive folder.The containing folders for the pin board are created, but the file never uploads, and I get some errors and warnings.
Created on 2023-09-01 with reprex v2.0.2
Thanks!