-
Notifications
You must be signed in to change notification settings - Fork 48
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_put
may not account for type
conversion when deciding whether file already exists
#461
Comments
I don't remember thinking about file type when working on this. What you describe above feels like a bug, though. It would be great to get an actual reprex (vs. pseudo-code), though. |
library('googledrive')
# before running the code,
# create a file email.txt containing the email address for your google account,
# create a google drive folder and copy its url into folder-url.txt,
# create word files drive-file-1.docx and drive-file-2.docx
email = readLines('email.txt')
folder_url = readLines('folder-url.txt')
media1 = 'drive-file-1.docx'
media2 = 'drive-file-2.docx'
drive_auth(email = email)
# ok
drive_put(media1, folder_url, name = media1)
#> ℹ No pre-existing Drive file at this path. Calling `drive_upload()`.
#> Local file:
#> • 'drive-file-1.docx'
#> Uploaded into Drive file:
#> • 'drive-file-1.docx' <id: 1GXSI0LjSxE1pfIyDzwnHAc3ydlbrYmN->
#> With MIME type:
#> • 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
drive_ls(folder_url)
#> # A dribble: 1 × 3
#> name id drive_resource
#> <chr> <drv_id> <list>
#> 1 drive-file-1.docx 1GXSI0LjSxE1pfIyDzwnHAc3ydlbrYmN- <named list [42]>
drive_put(media1, folder_url, name = media1)
#> ℹ A Drive file already exists at this path. Calling `drive_update()`.
#> File updated:
#> • 'drive-file-1.docx' <id: 1GXSI0LjSxE1pfIyDzwnHAc3ydlbrYmN->
drive_ls(folder_url)
#> # A dribble: 1 × 3
#> name id drive_resource
#> <chr> <drv_id> <list>
#> 1 drive-file-1.docx 1GXSI0LjSxE1pfIyDzwnHAc3ydlbrYmN- <named list [42]>
# not ok
drive_put(media2, folder_url, type = 'document', name = media2)
#> ℹ No pre-existing Drive file at this path. Calling `drive_upload()`.
#> Local file:
#> • 'drive-file-2.docx'
#> Uploaded into Drive file:
#> • 'drive-file-2' <id: 1W5N5VzzW3HkgokARPtmHuh6wRAMfeTEteTLtxtXbCmA>
#> With MIME type:
#> • 'application/vnd.google-apps.document'
drive_ls(folder_url)
#> # A dribble: 2 × 3
#> name id drive_resource
#> <chr> <drv_id> <list>
#> 1 drive-file-2 1W5N5VzzW3HkgokARPtmHuh6wRAMfeTEteTLtxtXbCmA <named list>
#> 2 drive-file-1.docx 1GXSI0LjSxE1pfIyDzwnHAc3ydlbrYmN- <named list>
drive_put(media2, folder_url, type = 'document', name = media2)
#> ℹ No pre-existing Drive file at this path. Calling `drive_upload()`.
#> Local file:
#> • 'drive-file-2.docx'
#> Uploaded into Drive file:
#> • 'drive-file-2' <id: 1uOxI-QOmzbzHe0t5S6qxCtul8YoZzA9Wa1fxXmfJe_8>
#> With MIME type:
#> • 'application/vnd.google-apps.document'
drive_ls(folder_url)
#> # A dribble: 3 × 3
#> name id drive_resource
#> <chr> <drv_id> <list>
#> 1 drive-file-2 1uOxI-QOmzbzHe0t5S6qxCtul8YoZzA9Wa1fxXmfJe_8 <named list>
#> 2 drive-file-2 1W5N5VzzW3HkgokARPtmHuh6wRAMfeTEteTLtxtXbCmA <named list>
#> 3 drive-file-1.docx 1GXSI0LjSxE1pfIyDzwnHAc3ydlbrYmN- <named list> Created on 2024-09-09 with reprex v2.1.1 |
@jennybc what do you think? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, here's the behavior I'm observing in pseudocode.
Is this expected? Am I doing something wrong? Thanks!
The text was updated successfully, but these errors were encountered: