Giter VIP home page Giter VIP logo

rdrop2's Introduction

rdrop2 - Dropbox interface from R a_box

🚨🚨🚨 Call for maintainers 🚨🚨🚨

The package is currently not maintained and up for adoption. If you are interested in taking over as maintainer, please send an email to [email protected].

If we can't find another maintainer before something breaks on CRAN, the package will be archived. 🙏 🚨🚨🚨


Project Status: Active – The project has reached a stable, usable state and is being actively developed. Build Status Coverage Status CRAN_Status_Badge DOI

Maintainers: Karthik Ram (@karthik) and Clayton Yochum (@ClaytonJY)

This package provides programmatic access to Dropbox from R. The functions in this package provide access to a full suite of file operations, including dir/copy/move/delete operations, account information and the ability to upload and download files from any Dropbox account.

Installation

# Current CRAN version (0.8.1)
install.packages('rdrop2')

# or the development version (0.8.1.9999)
devtools::install_github("karthik/rdrop2")

Authentication

library(rdrop2)
drop_auth()
# This will launch your browser and request access to your Dropbox account. You will be prompted to log in if you aren't already logged in.
# Once completed, close your browser window and return to R to complete authentication. 
# The credentials are automatically cached (you can prevent this) for future use.

# If you wish to save the tokens, for local/remote use

token <- drop_auth()
saveRDS(token, file = "token.rds")

# Then in any drop_* function, pass `dtoken = token
# Tokens are valid until revoked.

Retrieve Dropbox account information

library(dplyr)
drop_acc() %>% data.frame()
# Returns the following fields
# [1] "account_id"            "name.given_name"      
#  [3] "name.surname"          "name.familiar_name"   
#  [5] "name.display_name"     "name.abbreviated_name"
#  [7] "email"                 "email_verified"       
#  [9] "disabled"              "country"              
# [11] "locale"                "referral_link"        
# [13] "is_paired"             ".tag"        

Dropbox directory listing

write.csv(mtcars, "mtcars.csv")
drop_upload("mtcars.csv")
drop_dir()
# If your account is not empty, it returns the following fields
#  [1] ".tag"            "name"            "path_lower"     
#  [4] "path_display"    "id"              "client_modified"
#  [7] "server_modified" "rev"             "size"           
# [10] "content_hash"   
#
# 
# or specify a path
drop_dir('public/gifs')
.tag name path_lower path_display id client_modified server_modified rev size content_hash
file mtcars.csv /mtcars.csv /mtcars.csv id:b-ac9BwzYUAAAAAAAAAxFQ 2017-09-27T16:21:56Z 2017-09-27T16:21:57Z 691634207848 1783 8c00dcec5f3e6bf58a42dcf354f0d5199a43567e88a9d80291bd2b85f53a54a5

Filter directory listing by object type (file/folder)

drop_dir() %>% 
    filter(.tag == "folder")

Create folders on Dropbox

drop_create('drop_test')
# or provide the full path where it needs to be created
drop_create('public/drop_test')

Upload a file into Dropbox

csv files

write.csv(mtcars, 'mtcars.csv')
drop_upload('mtcars.csv')
# or upload to a specific folder
drop_upload('mtcars.csv', path = "drop_test")

You can also do this for any other file type and large files are supported regardless of your memory.

Download a file

drop_download('mtcars.csv')
# or add path if file is not in root
drop_download("test_folder/mtcars.csv")

Delete a file

drop_delete('mtcars.csv')

Move files

drop_create("new_folder")
drop_move("mtcars.csv", "new_folder/mtcars.csv")

Copy files

drop_create("new_folder2")
drop_copy("new_folder/mtcars.csv", "new_folder2/mtcars.csv")

Search and download files

I frequently use a duck season rabbit season gif. This is how I could search and download from my public Dropbox account.

x <- drop_search("rabbit")
drop_download(x$matches[[1]]$metadata$path_lower, local_path = '~/Desktop/bugs.gif')

# Downloaded /public/gifs/duck_rabbit.gif to ~/Desktop/bugs.gif: 329.2 Kb on disk

Read csv files directly from Dropbox

write.csv(iris, file = "iris.csv")
drop_upload("iris.csv")
# Now let's read this back into an R session
# Note that there is a quiet download happening to your temp dir
new_iris <- drop_read_csv("iris.csv")

Accessing Dropbox on Shiny and remote servers

If you expect to access a Dropbox account via Shiny or on a remote cluster, EC2, Digital Ocean etc, you can leave the cached oauth file in the same directory, or pass the token explicitly to drop_auth. You can also save the output of drop_auth into an R object, sink that to disk, and pass that as a token. If using on Travis or similar, you should consider encrypting the oauth cache file to prevent unauthorized access to your Dropbox account. If you have multiple tokens and accounts, it is also possible to override the environment token and explicitly pass a specific token for each drop_ function.

token <- drop_auth()
saveRDS(token, "droptoken.rds")
# Upload droptoken to your server
# ******** WARNING ********
# Losing this file will give anyone 
# complete control of your Dropbox account
# You can then revoke the rdrop2 app from your
# dropbox account and start over.
# ******** WARNING ********
# read it back with readRDS
token <- readRDS("droptoken.rds")
# Then pass the token to each drop_ function
drop_acc(dtoken = token)

Meta

  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

  • For bug reports and known problems, please look over the issues before filing a new report.

rdrop2's People

Contributors

andersvr avatar claytonjy avatar daattali avatar fcampelo avatar imgbotapp avatar karthik avatar richfitz avatar rosseji avatar scheidec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rdrop2's Issues

Feature Request: Date Parser

Can we get a date parser for the modified field returned by e.g. drop_dir()?

Consider this ...

    library(rdrop2)

    drop_auth()
    files_and_folders <- drop_dir()

    files_and_folders$modified %>% head(5)
    ## [1] "Wed, 03 Jun 2015 09:27:11 +0000" "Thu, 07 Jan 2016 10:05:52 +0000"
    ## [3] "Wed, 01 Feb 2012 12:21:22 +0000" "Sat, 18 Oct 2014 08:15:01 +0000"
    ## [5] "Tue, 25 Nov 2014 14:14:00 +0000"

These are strings and very ugly to work with. No wouldn't it be nice to have function accompanying the package that allows to parse these strings into something one can work with?

Like this one? ...

    #' parse dropbox dates into POSIXct
    #' @param x dates to be parsed
    drop_as_posixct <- function(x){
      date  <- substring(x,6,16) 
      time  <- substring(x, 18, 25)
      day   <- substring(date, 1,2)
      year  <- substring(date, 8,12)

      month <- 
        substring(date, 4,6) %>% 
        match(
          c(
            "Jan", "Feb", "Mar", "Apr", 
            "May", "Jun", "Jul", "Aug",
            "Sep", "Oct", "Nov", "Dec"
          )
        ) 

      month[nchar(month)==1] <- 
        paste0("0", month[nchar(month)==1])

      date_time <- 
        paste0(year, "-", month, "-", day, " ", time)

      as.POSIXct(date_time, tz="UTC")
    }

Now we get this ...

    drop_as_posixct(files_and_folders$modified) %>% head()
    ## [1] "2015-06-03 09:27:11 UTC" "2016-01-07 10:05:52 UTC" "2012-02-01 12:21:22 UTC"
    ## [4] "2014-10-18 08:15:01 UTC" "2014-11-25 14:14:00 UTC" "2014-10-28 08:53:17 UTC"

... and can do stuff like that ...

    drop_as_posixct(files_and_folders$modified) > (Sys.time() - 60*60*24*30)
    ## [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
    ## [14] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
    ## [27] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
    ## [40] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

If you think this is worth putting in - I would thinks so - I can make a pull request. But I am not sure where to best put this that it gets integrated nicely into the package - i.e. should it be a separate function or should it be an un-exported helper that gets called automatically for stuff like drop_dir() and the user than gets already parsed time stamps in return?

drop_dir fails with verbose=TRUE

Commenting out lines 51,93 and 94 solves the problem - it's something to do with the res$contents not being in the form the print statements expect.

two-factor auth

have you tested this on 2-factor auth? i tried authing, and it didn't work, not sure if it's just me

CSV file not being overwritten.

Thank you for your app.
It works very well. However, the problem I have is drop_upload a csv file with overwrite=TRUE. This argument is being ignored or the problem is with DropBox sync. Some files get over-written, others don't. But, I added code to check if drop_exists, drop_delete if TRUE, then drop_upload and this works.

Outofbounds Authentication Fails with Invalid URL

Installed rdrop2 on my local workstation, which output the following:

![drop2400](https://cloud.githubusercontent.com/assets/815126/10033032/18ab4522-6187-11e5-8ae0-08bbda07c785.png)
![drop2400](https://cloud.githubusercontent.com/assets/815126/10033045/34e23d4a-6187-11e5-9950-2bf5045598a4.png)
> install.packages("rdrop2")
Installing package into ‘/home/phillc/R/x86_64-pc-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
--2015-09-22 23:45:09--  https://cran.rstudio.com/src/contrib/rdrop2_0.7.0.tar.gz
Resolving cran.rstudio.com (cran.rstudio.com)... 54.230.45.109
Connecting to cran.rstudio.com (cran.rstudio.com)|54.230.45.109|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16304 (16K) [application/x-gzip]
Saving to: ‘/tmp/RtmpVLF3lv/downloaded_packages/rdrop2_0.7.0.tar.gz’

     0K .......... .....                                      100%  130M=0s

2015-09-22 23:45:10 (130 MB/s) - ‘/tmp/RtmpVLF3lv/downloaded_packages/rdrop2_0.7.0.tar.gz’ saved [16304/16304]

* installing *source* package ‘rdrop2’ ...
** package ‘rdrop2’ successfully unpacked and MD5 sums checked
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (rdrop2)

The downloaded source packages are in
    ‘/tmp/RtmpVLF3lv/downloaded_packages’
> library(rdrop2)
> drop_auth()
httpuv not installed, defaulting to out-of-band authentication
Please point your browser to the following url: 

  https://www.dropbox.com/1/oauth2/authorize?client_id=mmhfsybffdom42w&scope=&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code

Enter authorization code: 

The URL provided fails with a 400 error. See attached screen shot.

rdrop2 version is 0.7.

I did not have devtools installed at the time.

drop2400

oauth_listener() needs an interactive environment

I built a Shiny application with an action button which downloads pdfs hosted in a Dropbox folder. It uses:

drop_media(): to generate the link to download the specific pdf file
browseURL(): to access the generated link

It works perfectly on my computer. However, when I publish it, the download function does not work and I get the following message: Disconnected from the server. Reload.

Looking at the log file, it throws the following error: Warning: Error in : oauth_listener() needs an interactive environment.

I´m a beginner on this type of applications. The Dropbox token is placed on the main directory, and published with the rest of the files.

The application connects successfully to the Dropbox folder in other parts of the code(global.r, server.r), but where it gets stucked is in this one:

fndownload=eventReactive(input$downloadpdf,{
    urr=drop_media("example.pdf", dtoken=token)
    urr$url
})

observeEvent(input$downloadpdf, {
    browseURL(fndownload())
})

Originnaly, the fndownload function was within the obserEvent but I got the same error as well.

There is not much information regarding remote storage Dropbox Shiny applications, but quite few threads regarding the same issue with other remote storage platforms (e.g. gsheets).

Any help will be awesome. Regards

Cascading errors from drop_dir(..., file_limit = 1000,...)

The file count limit in drop_dir() causes cascading errors, primarily because drop_dir() is used in drop_exists(), which in turn is used as an error checker in other conditions. So when I go to drop_get() a file in a directory of over 1000, I get an error because it says the file doesn't exist.

Some suggestions:

  1. drop_dir() should print a verbose warning when it gets an error in response to asking for a folder with too many files. ("406 Error: Folder contains more entries than file_limit (1000)")
  2. For drop_exists(), don't use drop_dir() to determine file existence but instead make a request to the /metadata/... for the file. (A function to get the metadata of one file might be useful, anyway).
  3. Since drop_dir() is used internally elsewhere, perhaps this parameter should be a package option.
  4. Or drop_dir() could automatically run again with a higher file limit if encountering this error.

Of these, (1) and (2) seem best.

(I note that the docs say the default is file_limit 10,000 but the current actual default is 1000. I think this is because the docs are taken straight from the Dropbox API docs.)

Get version history

I would very much like to be able to programmatically retrieve the version history of a dropbox file. I suggest a drop_history() command, which would list the version history of a file, and then an argument to drop get, e.g., drop_get(..., version = VERSION). We do this in driver, and version can either take the version number or a date, in which case it will retrieve the last version prior to that date.

httr error with old token files

If drop_acc is used with a token generated while a <1.0.0 version of httr is installed, after updating httr, this cryptic error is thrown by httr:

Error: is.request(y) is not TRUE

This can be solved by re-generating the token file (or rolling back the httr version) but the error message is particularly unhelpful. It might be useful to add a warning about this.

drop_upload timeout

Error in curl::curl_fetch_memory(url, handle = handle) :
Timeout was reached
Calls: drop_upload ... request_fetch -> request_fetch.write_memory -> -> .Call

I sometimes get this error, above all when the internet is a bit slow. Is it possible to allow a bit more time before the time out or to parametrize it ?

Quite annoying to have a script failing just because a very strict time out

Request for pause/resume sync

While trying to maintain a couple of databases and frequently-accessed files, and a GitHub repository, on Dropbox, I have pretty consistently found occasional, hard-to-diagnose, impossible to replicate errors that I think are caused by Dropbox and other programs fighting over access to files -- generally files that you would expect the program to want exclusive access to while active.

For me, all those problems completely vanished when I made it a practice to always pause sync before running any program that wants access to Dropbox files while running. Except, of course, when I forgot to.

So If I am going to host any working directories on Dropbox, as I now do, I would like a function I could set up to automatically pause sync before R opens any directory on dropbox, and then resume on exit.

Would that be an appropriate addition to your package?

--Andrew

share data files without authorization

It might be worth it to note a simple way to read data files without authorization:

# link provided by Dropbox:
# https://www.dropbox.com/s/gi5xia1b2r11bez/311%20Calls%20for%20Disorderly%20Youth.csv?dl=0
# change dl=0 to dl=1

dat <- read.csv( "https://www.dropbox.com/s/gi5xia1b2r11bez/311%20Calls%20for%20Disorderly%20Youth.csv?dl=1" )

drop_create() authentication error

I am using several functions from rdrop2 package on in a shiny app. I am using a rds token file for authentication purpose. All the functions work well apart from drop_create().

Same issues arises on RStudio server also. Every other function works but re-authentication is required when I use drop_create().

Furthermore the authentication also doesn't work, I have set httr_oob_default = TRUE but when I go to the url generated for authentication token, I get a 400 error with the message:

Invalid redirect_uri. When response_type=code, redirect_uri must start with "https://", unless it's a localhost URI.

If I do the same on RStudio desktop, drop_create() works perfectly with the same token. Can someone guide me if I am missing anything here?

Error in drop_dir()

When I run drop_dir(), I get the following error:

Error: All select() inputs must resolve to integer column positions.
The following do not:
*  mime_type

This occurs in the last command, (%>% dplyr::select(path, mime_type, root, bytes, modified). When I run the command in debug mode, I find that res$contents does not have a mime_type column.

I also note that when I run with verbose=TRUE, I get this error:

Error in cat(list(...), file, sep, fill, labels, append) : 
  argument 3 (type 'list') cannot be handled by 'cat'
In addition: Warning message:
In if (value == "") next :
  the condition has length > 1 and only the first element will be used

This occurs in pretty_lists() when it attempts to print the $content element.

drop_delete with saved token fails in cloud

Encountered unexpected behavior with running the following code:

#token_drop <- drop_auth() #initialized in first run
#saveRDS(token_drop, "/path/to/droptoken.rds")
token_drop <- readRDS("/path/to/droptoken.rds")
drop_acc(dtoken=token_drop, verbose = TRUE)
#get a list of items in the directory
data <- drop_dir("/list/items", dtoken = token_drop)
#get the first item on the drop box list
drop_get(as.character(data[1,1]),local_file = "dt_items.Rdata" ,dtoken = token_drop, overwrite = TRUE)
#load the data.table to environment
load(paste0(getwd(),"/dt_items.Rdata"))
#remove the local file
file.remove(paste0(getwd(),"/dt_items.Rdata"))
#remove the dropbox file
drop_delete(as.character(data[1,1]), dtoken = token_drop)

The drop_dir and drop_get run without starting the oauth flow Expected.

drop_delete always causes browser to open a window for oauth flow. Unexpected.
Shouldn't this follow suit with drop_get and not start the oauth because token is provided?

Happens with dev and cran version. EDIT:And added bonus is that I run R in Google Cloud


> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Debian GNU/Linux 8 (jessie)
> 
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
>  [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
> [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base     
> 
> other attached packages:
> [1] dplyr_0.4.3          rdrop2_0.7           data.table_1.9.6     bigrquery_0.1.0.9000
> [5] httr_1.1.0.9000      PKI_0.1-3            base64enc_0.1-3     
> 
> loaded via a namespace (and not attached):
>  [1] Rcpp_0.12.4     digest_0.6.9    withr_1.0.1     assertthat_0.1  chron_2.3-47    R6_2.1.2       
>  [7] jsonlite_0.9.19 DBI_0.4         git2r_0.13.1    magrittr_1.5    lazyeval_0.1.10 curl_0.9.7     
> [13] devtools_1.11.1 tools_3.2.3     httpuv_1.3.3    parallel_3.2.3  memoise_1.0.0   openssl_0.9.2  
> > library(devtools)
> > session_info()
> Session info ----------------------------------------------------------------------------------------------
>  setting  value                       
>  version  R version 3.2.3 (2015-12-10)
>  system   x86_64, linux-gnu           
>  ui       RStudio (0.99.491)          
>  language (EN)                        
>  collate  en_US.UTF-8                 
>  tz       <NA>                        
>  date     2016-05-02                  
> 
> Packages --------------------------------------------------------------------------------------------------
>  package    * version    date       source                              
>  assertthat   0.1        2013-12-06 CRAN (R 3.2.3)                      
>  base64enc  * 0.1-3      2015-07-28 CRAN (R 3.2.3)                      
>  bigrquery  * 0.1.0.9000 2016-02-27 Github (rstats-db/bigrquery@2866909)
>  chron        2.3-47     2015-06-24 CRAN (R 3.2.3)                      
>  curl         0.9.7      2016-04-10 CRAN (R 3.2.3)                      
>  data.table * 1.9.6      2015-09-19 CRAN (R 3.2.3)                      
>  DBI          0.4        2016-05-02 CRAN (R 3.2.3)                      
>  devtools   * 1.11.1     2016-04-21 CRAN (R 3.2.3)                      
>  digest       0.6.9      2016-01-08 CRAN (R 3.1.1)                      
>  dplyr      * 0.4.3      2015-09-01 CRAN (R 3.2.3)                      
>  git2r        0.13.1     2015-12-10 CRAN (R 3.2.3)                      
>  httpuv       1.3.3      2015-08-04 CRAN (R 3.2.3)                      
>  httr       * 1.1.0.9000 2016-04-28 Github (hadley/httr@7261a52)        
>  jsonlite     0.9.19     2015-11-28 CRAN (R 3.2.3)                      
>  lazyeval     0.1.10     2015-01-02 CRAN (R 3.2.3)                      
>  magrittr     1.5        2014-11-22 CRAN (R 3.1.1)                      
>  memoise      1.0.0      2016-01-29 CRAN (R 3.2.3)                      
>  openssl      0.9.2      2016-02-26 CRAN (R 3.2.3)                      
>  PKI        * 0.1-3      2015-07-28 CRAN (R 3.2.3)                      
>  R6           2.1.2      2016-01-26 CRAN (R 3.2.3)                      
>  Rcpp         0.12.4     2016-03-26 CRAN (R 3.2.3)                      
>  rdrop2     * 0.7        2016-05-02 Github (karthik/rdrop2@15e59ef)     
>  withr        1.0.1      2016-02-04 CRAN (R 3.2.3)  

Issue with folder names with capital letter ?

drop_dir('AFL_Resources/Model/db')
Source: local data frame [6 x 5]

                                        path mime_type    root  bytes                        modified

1            /AFL_Resources/model/db/afl.csv  text/csv dropbox 354595 Mon, 11 May 2015 17:55:34 +0000
2 /AFL_Resources/model/db/lookup_stadium.csv  text/csv dropbox   2234 Mon, 11 May 2015 17:55:34 +0000
3        /AFL_Resources/model/db/stadium.csv  text/csv dropbox    924 Mon, 11 May 2015 17:55:34 +0000
4   /AFL_Resources/model/db/team_stadium.csv  text/csv dropbox   1689 Mon, 11 May 2015 17:55:34 +0000
5           /AFL_Resources/model/db/team.csv  text/csv dropbox    638 Mon, 11 May 2015 17:55:34 +0000
6    /AFL_Resources/model/db/teamStadium.csv  text/csv dropbox   3451 Mon, 11 May 2015 17:55:34 +0000

aflData <- drop_read_csv(file = "AFL_Resources/Model/db/afl.csv")
File not found on Dropbox 

Capital letter seems to be the problem as if I rename Model in model then it works fine

 drop_dir('AFL_Resources/model/db')
                                        path mime_type    root  bytes                        modified
1            /AFL_Resources/model/db/afl.csv  text/csv dropbox 354595 Mon, 11 May 2015 17:55:34 +0000
2 /AFL_Resources/model/db/lookup_stadium.csv  text/csv dropbox   2234 Mon, 11 May 2015 17:55:34 +0000
3        /AFL_Resources/model/db/stadium.csv  text/csv dropbox    924 Mon, 11 May 2015 17:55:34 +0000
4   /AFL_Resources/model/db/team_stadium.csv  text/csv dropbox   1689 Mon, 11 May 2015 17:55:34 +0000
5           /AFL_Resources/model/db/team.csv  text/csv dropbox    638 Mon, 11 May 2015 17:55:34 +0000
6    /AFL_Resources/model/db/teamStadium.csv  text/csv dropbox   3451 Mon, 11 May 2015 17:55:34 +0000

aflData <- drop_read_csv(file = "/AFL_Resources/model/db/afl.csv")
/tmp/RtmpYIbY9x/afl.csv on disk 354.595 KB

Notice: Changing package name

I've decided to change the name from rdrop2 (which really only makes sense to the original users) to dropr (pronounced dropper). I'll make this change over the next few days. Functionally nothing will change, but users will have to reinstall after the update.

Recursive drop_get

I might be missing something but I don't see support for downloading entire directories? It looks from a random bit of googling suggests that this could be possible but that possibly falls outside of the API?

When calling drop_get on a directory I get json saying:

{"error": "Path is a directory"}

though drop2 does not convert this to an error (I suggest a httr::stop_for_status(x) after the GET as dropbox is sending a 500 status with the response).

Version: 0.7.0 (CRAN) which looks close to the current GH version.

Unrelated; the authentication dance is slick. Really nicely done.

Error in curl::curl_escape(names(url$query)) : `url` must be a character vector.

It seems that the default "rev" can cause error. Thanks!

drop_get("temp")
Error in curl::curl_escape(names(url$query)) :
url must be a character vector.
drop_get("temp", rev="")

temp on disk 6875.423 KB

sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] curl_0.8 httr_1.0.0 rdrop2_0.6.6.99

loaded via a namespace (and not attached):
[1] assertthat_0.1 DBI_0.3.1 digest_0.6.4 dplyr_0.4.0 httpuv_1.3.0 jsonlite_0.9.10
[7] lazyeval_0.1.10 magrittr_1.5 mime_0.1.2 parallel_3.1.1 R6_2.0.1 Rcpp_0.11.2
[13] stringi_0.4-1 stringr_1.0.0 tools_3.1.1

Media URLs not working correctly

When testing the package, I am getting the following error:

2. Failure: Media URLs work correctly (@test-rdrop2.R#187) ---------------------
media_url$url produced no output

Which is coming from these lines in the test-rdrop2.R file:

# drop_media
context("Testing Media URLs")

test_that("Media URLs work correctly", {
     skip_on_cran()
    download.file("http://media4.giphy.com/media/YaXcVXGvBQlEI/200.gif", destfile = "duck_rabbit.gif")
    drop_upload("duck_rabbit.gif")
    media_url <- drop_media("duck_rabbit.gif")
    expect_output(media_url$url, "https://dl.dropboxusercontent.com")
    unlink("duck_rabbit.gif")
    unlink("*.csv")
})

Here is my session info:

> devtools::session_info("rdrop2")
Session info --------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.1 (2017-06-30)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.0.153)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/New_York            
 date     2017-09-12                  

Packages ------------------------------------------------------------------------------------------------------------
 package    * version  date       source         
 assertthat   0.2.0    2017-04-11 CRAN (R 3.4.0) 
 BH           1.62.0-1 2016-11-19 CRAN (R 3.4.0) 
 bindr        0.1      2016-11-13 CRAN (R 3.4.0) 
 bindrcpp     0.2      2017-06-17 CRAN (R 3.4.0) 
 curl         2.6      2017-04-27 CRAN (R 3.4.0) 
 data.table   1.10.4   2017-02-01 CRAN (R 3.4.0) 
 dplyr        0.7.2    2017-07-20 CRAN (R 3.4.1) 
 glue         1.1.1    2017-06-21 CRAN (R 3.4.1) 
 graphics   * 3.4.1    2017-07-07 local          
 grDevices  * 3.4.1    2017-07-07 local          
 httr         1.2.1    2016-07-03 CRAN (R 3.4.0) 
 jsonlite     1.5      2017-06-01 cran (@1.5)    
 magrittr     1.5      2014-11-22 CRAN (R 3.4.0) 
 methods    * 3.4.1    2017-07-07 local          
 mime         0.5      2016-07-07 CRAN (R 3.4.0) 
 openssl      0.9.6    2016-12-31 CRAN (R 3.4.0) 
 pkgconfig    2.0.1    2017-03-21 CRAN (R 3.4.0) 
 plogr        0.1-1    2016-09-24 CRAN (R 3.4.0) 
 R6           2.2.2    2017-06-17 cran (@2.2.2)  
 Rcpp         0.12.12  2017-07-15 cran (@0.12.12)
 rdrop2       0.7      2017-09-11 local          
 rlang        0.1.2    2017-08-09 cran (@0.1.2)  
 stats      * 3.4.1    2017-07-07 local          
 tibble       1.3.3    2017-05-28 cran (@1.3.3)  
 tools        3.4.1    2017-07-07 local          
 utils      * 3.4.1    2017-07-07 local   

Any idea as to how this failure could be produced?

This failure has been occurring for the last 8 months: https://travis-ci.org/karthik/rdrop2/builds/196017758#L1601

Request: Generic `drop_read` function

I think drop_read_csv defines a really useful pattern: drop_get to a local tempfile, then use read.csv on it. There's a hard limitation on read.csv; if I want to use, say readr::read_csv, I have to re-implement the function changing just that last line (and adding rdrop2::: to the dtoken arg).

I do this a lot, and I suspect it'd be helpful to others to make this easier and enforce good usage.

How about a function drop_read that looks roughly like this?

drop_read <- function(file, function, dest = tempdir(), dtoken = get_dropbox_token(), ...) {

  localfile = paste0("dest, "/", basename(file))

  drop_get(file, local_file = localfile, overwrite = TRUE, dtoken = dtoken)

  function(localfile, ...)  # maybe rlang::as_function?
}

There's no real reason this has to be read-specific, so it could be named something more generic; drop_do? Then drop_read_csv could be a slim wrapper around this new thing.

I'd be happy to file a PR, but I know @karthik is in the middle of API v2 refactoring and I don't want this to get lost in the shuffle.

(p.s. Karthik I'd love to help with that refactoring, just not sure where you're at or what the plan is)

drop_search fails when searching for strings that are also folder names

When I search for a file with drop_search that happens to have the same name / stem as another folder in dropbox, the search fails (sometimes). The example below fails for the public folder. However, when I did the same thing with the personal folder (put personal.csv) in it, it doesn't fail. But when I drop_search for my surname (lots of files and folders with that string in the name in my dropbox) it does fail. So, I haven't figured out the pattern yet, but I assume there is one...

> packageVersion("rdrop2")
[1] ‘0.7.0’
> write.csv(iris, file = "public.csv")
> drop_upload('public.csv', dest = "Public")
File public.csv uploaded successfully
> drop_search("public")
Error in data.table::rbindlist(zz, fill = T) : 
  Column 14 of item 110 is length 2, inconsistent with first column of that item which is length 1. rbind/rbindlist doesn't recycle as it already expects each item to be a uniform list, data.frame or data.table

Great package, by the way!

Error when calling drop_share using a variable as path name

I'm attempting to iterate over a directory of files to get a list of URLs (share URLs). When I do this by passing a variable in for the path argument in drop_share function, I receive an error: error = The input field 'path.path' was not expected." When I pass in the actual string contained in the variable passed in, drop_share works fine.

Below is an example of my code that I was writing to test this functionality:

files <- drop_dir(path = "Sharing Folder/SP16SSTRosterValidation")

for (i in 1:nrow(files)) {
    locat <- files[i,1]
    drop_share(locat)
}

curl::curl_fetch_memory

Hi.
I m using rdrop2 on a ec3 running a shiny-server on ubuntu 16.04 64 bits and R version 3.3.3 . Everything was running smoothly, then I made a feel changes to the app, tested locally (it was and still is everything ok), commited to my server, but then the app don't load anymore. I've tried to undo all my changes, but apparently it isn't related to them. Then I commented the section where I was using rdrop2, and the app loaded again on the server.

This is the section that is causing the problem:

library(rdrop2)
tesT=readRDS("data/test.rds") 
data=drop_read_csv("shiny/autismo/data/dados.csv",dtoken=tesT)
gruposcsv=drop_read_csv("shiny/autismo/data/grupos.csv",dtoken=tesT)

This is my last logfile:
Warning: Error in curl::curl_fetch_memory: Failure when receiving data from the peer
Stack trace (innermost first):
49: curl::curl_fetch_memory
48: request_fetch.write_memory
47: request_fetch
46: request_perform
45: httr::GET
44: drop_dir_internal
43: drop_exists
42: drop_get
41: drop_read_csv
1: runApp
Error : An error has occurred. Check your logs or contact the app author for clarification.

Any idea about how can I fix this?

Extra headers in csv file uploads

When I upload csv files using drop_upload, there are extra headers, and a revision hash written at the end of the file. This makes it diffcult to download (using drop_get) and read into R (using read_csv) without manually deleting those extra data before the header row and after the last row.

How to replicate

devtools::install_github('karthik/rDrop2')
library(rDrop2)
write.csv(mtcars, "mt.csv")
drop_upload("mt.csv", verbose = TRUE)
# revision = 144699832 
# bytes = 1981 
# thumb_exists = FALSE 
# rev = 89ff1b80037fcc7 
# modified = Sun, 05 Apr 2015 18:32:40 +0000 
# shareable = FALSE 
# mime_type = text/csv 
# path = /mt.csv 
# is_dir = FALSE 
# size = 1.9 KB 
# root = dropbox 
# client_mtime = Sun, 05 Apr 2015 18:32:40 +0000 
# icon = page_white 

File uploads successfully. However, mt.csv looks like this on Dropbox.

--------------------------4b41bc551a154288
Content-Disposition: form-data; name="data"; filename="mt.csv"
Content-Type: application/octet-stream

"","mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"
"Mazda RX4",21,6,160,110,3.9,2.62,16.46,0,1,4,4
"Mazda RX4 Wag",21,6,160,110,3.9,2.875,17.02,0,1,4,4
"Datsun 710",22.8,4,108,93,3.85,2.32,18.61,1,1,4,1
"Hornet 4 Drive",21.4,6,258,110,3.08,3.215,19.44,1,0,3,1
"Hornet Sportabout",18.7,8,360,175,3.15,3.44,17.02,0,0,3,2
"Valiant",18.1,6,225,105,2.76,3.46,20.22,1,0,3,1
"Duster 360",14.3,8,360,245,3.21,3.57,15.84,0,0,3,4
"Merc 240D",24.4,4,146.7,62,3.69,3.19,20,1,0,4,2
"Merc 230",22.8,4,140.8,95,3.92,3.15,22.9,1,0,4,2
"Merc 280",19.2,6,167.6,123,3.92,3.44,18.3,1,0,4,4
"Merc 280C",17.8,6,167.6,123,3.92,3.44,18.9,1,0,4,4
"Merc 450SE",16.4,8,275.8,180,3.07,4.07,17.4,0,0,3,3
"Merc 450SL",17.3,8,275.8,180,3.07,3.73,17.6,0,0,3,3
"Merc 450SLC",15.2,8,275.8,180,3.07,3.78,18,0,0,3,3
"Cadillac Fleetwood",10.4,8,472,205,2.93,5.25,17.98,0,0,3,4
"Lincoln Continental",10.4,8,460,215,3,5.424,17.82,0,0,3,4
"Chrysler Imperial",14.7,8,440,230,3.23,5.345,17.42,0,0,3,4
"Fiat 128",32.4,4,78.7,66,4.08,2.2,19.47,1,1,4,1
"Honda Civic",30.4,4,75.7,52,4.93,1.615,18.52,1,1,4,2
"Toyota Corolla",33.9,4,71.1,65,4.22,1.835,19.9,1,1,4,1
"Toyota Corona",21.5,4,120.1,97,3.7,2.465,20.01,1,0,3,1
"Dodge Challenger",15.5,8,318,150,2.76,3.52,16.87,0,0,3,2
"AMC Javelin",15.2,8,304,150,3.15,3.435,17.3,0,0,3,2
"Camaro Z28",13.3,8,350,245,3.73,3.84,15.41,0,0,3,4
"Pontiac Firebird",19.2,8,400,175,3.08,3.845,17.05,0,0,3,2
"Fiat X1-9",27.3,4,79,66,4.08,1.935,18.9,1,1,4,1
"Porsche 914-2",26,4,120.3,91,4.43,2.14,16.7,0,1,5,2
"Lotus Europa",30.4,4,95.1,113,3.77,1.513,16.9,1,1,5,2
"Ford Pantera L",15.8,8,351,264,4.22,3.17,14.5,0,1,5,4
"Ferrari Dino",19.7,6,145,175,3.62,2.77,15.5,0,1,5,6
"Maserati Bora",15,8,301,335,3.54,3.57,14.6,0,1,5,8
"Volvo 142E",21.4,4,121,109,4.11,2.78,18.6,1,1,4,2

--------------------------4b41bc551a154288--
mt.csv (END)

@hadley Any thoughts on why the boundary data is getting written into the file at the start and finish? I believe this is what is corrupting binary files and making csv files unreadable without manually deleting these extra data.

-> Content-Type: multipart/form-data; boundary=------------------------d2a5f7a5d436da57

Here is the API doc for this endpoint: https://www.dropbox.com/developers/core/docs#files_put

Deploying Shiny app to Shinyapps.io ,using rdrop2

I know the connection to dropbox is working,I have been able to create folders (Single_Cell_RNAseq_data) and move files.
My app is running fine when I run the app locally in R Studio ,the data gets uploaded from the dropbox and can be visualized.

saved the token locally

token <- drop_auth()
saveRDS(token, "droptoken.rds")

##in the global.r Script

token <- readRDS("droptoken.rds")
geneExpressionMatrix_yf1 <- drop_read_csv("Single_Cell_RNAseq_data/geneExpressionMatrix_yf1.csv",dtoken=token)

But while deploying on shinyapps.io, its throwing me this error.

An error has occurred
Unable to connect to worker after 60.00 seconds; startup took too long.

regular expressions in drop_search?

This might be a Dropbox API limitation -> would it be possible to use regular expressions instead of a string in drop_search?

I have files whose name ends with e.g. "_MP723.csv" vs. "_MP723_RAW.csv". The regexp for getting filenames such as the first one is "_MP....csv". Now I search for "MP csv" and then filter based on whether there is "RAW" in the filename.

Minimum changes needed for API v2

@karthik figured it'd be nice to have a list in one place. I think if we address all the v1 endpoints one by one, that should make sure we cover all our bases?

I'll start by listing them all then start going through the migration guide to determine which are straightforward and which require more effort.

From grep -r '/1/' ./:

  • ./R/drop_auth.R: authorize = "https://www.dropbox.com/1/oauth2/authorize",
  • ./R/drop_auth.R: access = "https://api.dropbox.com/1/oauth2/token"
  • ./R/drop_dir.R: metadata_url <- "https://api.dropbox.com/1/metadata/auto/"
  • ./R/drop_search.R: search_url <- "https://api.dropbox.com/1/search/auto/"
  • ./R/drop_delta.R: delta_url <- "https://api.dropbox.com/1/delta"
  • ./R/drop_upload.R: put_url <- "https://api-content.dropbox.com/1/files_put/auto/"
  • ./R/drop_file_ops.R: move_url <- "https://api.dropbox.com/1/fileops/copy"
  • ./R/drop_file_ops.R: move_url <- "https://api.dropbox.com/1/fileops/move"
  • ./R/drop_file_ops.R: create_url <- "https://api.dropbox.com/1/fileops/delete"
  • ./R/drop_file_ops.R: create_url <- "https://api.dropbox.com/1/fileops/create_folder"
  • ./R/drop_shared.R: share_url <- "https://api.dropbox.com/1/shares/auto/"
  • ./R/drop_history.R: rev_url <- "https://api.dropbox.com/1/revisions/auto/"
  • ./R/drop_acc.R: url <- "https://api.dropbox.com/1/account/info"
  • ./R/drop_get.R: get_url <- "https://api-content.dropbox.com/1/files/auto/"
  • ./R/drop_media.R: media_url <- "https://api.dropbox.com/1/media/auto/"

Using saved tokens

I've been trying to make an R package that uses rdrop2 to access a private shared folder on Dropbox. Everything works fine when I'm working interactively, using credentials stored by drop_acc(). However I've been trying to pass in my token (as described in the README). However I keep getting an error: File not found on Dropbox.
Not sure if I am misusing the token, or if this error message is misleading.

Error when `drop_dir` on an empty directory

I just created a directory on dropbox and wanted to test the drop_dir() function. I get

Error in print.default(., n = n) : invalid 'na.print' specification

If I add a file the function works fine, when I remove the file and the folder is empty again the error comes back.

Similarly, if a non-existent directory is given, then the same error shows. It'd be nicer to get a more informative "path does not exist" error.

rdrop v0.6.5.99

roadmap for next version

I hope to release the next CRAN version towards the end of May. Planned features

  • Support for Deltas, so Shiny users can update based on file changes
  • Progress bars for file uploads. The package can support uploads of any size, but currently it's not possible to predict progress on large files. Same with downloads.

If any users have other feature requests, please post below. The late May timeline works with CRAN's update policies although features will become available sooner here.

Error in credentials$access_token : $ operator is invalid for atomic vectors

Hi,
I have tried both stable version and development version.
I successfully completed the drop_auth().
However, when executing the other commands (e.g., drop_acc()), the same error was reported.

Error in credentials$access_token : $ operator is invalid for atomic vectors

Thanks!

My sessionInfo()

R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] rdrop2_0.6.6.99

loaded via a namespace (and not attached):
[1] assertthat_0.1 digest_0.6.4 httr_0.4 magrittr_1.5 RCurl_1.95-4.3 stringr_0.6.2 tools_3.1.1

drop_auth() Throws to Local Host, Cannot Load Page

After "Allowing" rdrop2 on Dropbox, I am re-directed to a local host page which cannot be loaded.

The URL, prior to clicking "Allow" shows the localhost re-direct:

https://www.dropbox.com/1/oauth2/authorize?client_id=mmhfsybffdom42w&scope=&redirect_uri=http%3A%2F%2Flocalhost%3A1410&response_type=code&state=axxpkm4iIq

After clicking allow I'm re-direct to http://localhost:1410 which cannot be loaded.

I confirm that I am logged into my Dropbox account.

I am using v0.7 of rdrop2, installed initially from CRAN and then from GitHub for the latest version.

My development environment is RStudio Server running on a remote Digital Ocean droplet.

My session info is:

> devtools::session_info()
Session info -------------------------------------------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.2 (2015-08-14)
 system   i486, linux-gnu             
 ui       RStudio (0.98.1083)         
 language (EN)                        
 collate  C                           
 tz       <NA>                        

Packages -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 package       * version   date       source                         
 DBI             0.3.1     2014-09-24 CRAN (R 3.2.2)                 
 R6              2.1.1     2015-08-19 CRAN (R 3.2.2)                 
 Rcpp            0.12.1    2015-09-10 CRAN (R 3.2.2)                 
 assertthat      0.1       2013-12-06 CRAN (R 3.2.2)                 
 chron           2.3-47    2015-06-24 CRAN (R 3.2.2)                 
 curl            0.9.3     2015-08-25 CRAN (R 3.2.2)                 
 data.table    * 1.9.6     2015-09-19 CRAN (R 3.2.2)                 
 devtools        1.8.0     2015-05-09 CRAN (R 3.2.2)                 
 digest          0.6.8     2014-12-31 CRAN (R 3.2.2)                 
 dplyr         * 0.4.3     2015-09-01 CRAN (R 3.2.2)                 
 git2r           0.11.0    2015-08-12 CRAN (R 3.2.2)                 
 htmltools       0.2.6     2014-09-08 CRAN (R 3.2.2)                 
 htmlwidgets     0.5       2015-06-21 CRAN (R 3.2.2)                 
 httpuv          1.3.3     2015-08-04 CRAN (R 3.2.2)                 
 httr            1.0.0     2015-06-25 CRAN (R 3.2.2)                 
 jsonlite        0.9.17    2015-09-06 CRAN (R 3.2.2)                 
 lpSolve       * 5.6.12    2015-09-01 CRAN (R 3.2.2)                 
 magrittr        1.5       2014-11-22 CRAN (R 3.2.2)                 
 memoise         0.2.1     2014-04-22 CRAN (R 3.2.2)                 
 mime            0.4       2015-09-03 CRAN (R 3.2.2)                 
 rdrop2        * 0.7       2015-09-22 Github (karthik/rdrop2@15e59ef)
 rhandsontable * 0.2       2015-08-25 CRAN (R 3.2.2)                 
 rstudio         0.98.1083 2015-09-08 local                          
 rstudioapi      0.3.1     2015-04-07 CRAN (R 3.2.2)                 
 rversions       1.0.2     2015-07-13 CRAN (R 3.2.2)                 
 shiny         * 0.12.2    2015-08-05 CRAN (R 3.2.2)                 
 shinyBS       * 0.61      2015-03-31 CRAN (R 3.2.2)                 
 stringi         0.5-5     2015-06-29 CRAN (R 3.2.2)                 
 stringr         1.0.0     2015-04-30 CRAN (R 3.2.2)                 
 xml2            0.1.2     2015-09-01 CRAN (R 3.2.2)                 
 xtable        * 1.7-4     2014-09-12 CRAN (R 3.2.2)  

error while downloading .rda files

Hi,

if i have a .rda file in dropbox, how do I download it?

this happens:
drop_get('duncan.rda')
Error: Path exists and overrwrite is FALSE

Shinyapps.io error: Warning: Error in : oauth_listener() needs an interactive environment.

Hi, when trying to pull data from my dropbox account for a shiny app I get this error. (shinyapps.io logs)

2016-03-19T23:18:38.148996+00:00 shinyapps[86118]: htmltools version: 0.3
2016-03-19T23:18:38.406392+00:00 shinyapps[86118]: Using jsonlite for JSON processing
2016-03-19T23:18:38.410372+00:00 shinyapps[86118]: 
2016-03-19T23:18:38.410375+00:00 shinyapps[86118]: Starting R with process ID: '12'
2016-03-19T23:18:38.430300+00:00 shinyapps[86118]: 
2016-03-19T23:18:38.430304+00:00 shinyapps[86118]: Listening on http://0.0.0.0:44020
2016-03-19T23:18:49.485827+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.485831+00:00 shinyapps[86118]: Attaching package: ‘dplyr’
2016-03-19T23:18:49.485832+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.486483+00:00 shinyapps[86118]: The following objects are masked from ‘package:stats’:
2016-03-19T23:18:49.486485+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.486487+00:00 shinyapps[86118]:     filter, lag
2016-03-19T23:18:49.492350+00:00 shinyapps[86118]: The following objects are masked from ‘package:base’:
2016-03-19T23:18:49.492353+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.492354+00:00 shinyapps[86118]:     intersect, setdiff, setequal, union
2016-03-19T23:18:49.492356+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573106+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573111+00:00 shinyapps[86118]: Attaching package: ‘magrittr’
2016-03-19T23:18:49.573112+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573392+00:00 shinyapps[86118]: The following object is masked from ‘package:tidyr’:
2016-03-19T23:18:49.486488+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573394+00:00 shinyapps[86118]:     extract
2016-03-19T23:18:49.642772+00:00 shinyapps[86118]: Warning: Error in : oauth_listener() needs an interactive environment.
2016-03-19T23:18:49.649738+00:00 shinyapps[86118]:     62: oauth_listener
2016-03-19T23:18:49.649739+00:00 shinyapps[86118]:     61: init_oauth2.0
2016-03-19T23:18:49.649741+00:00 shinyapps[86118]:     60: self$init_credentials
2016-03-19T23:18:49.649742+00:00 shinyapps[86118]:     59: public_bind_env$initialize
2016-03-19T23:18:49.649743+00:00 shinyapps[86118]:     58: Token2.0$new
2016-03-19T23:18:49.649744+00:00 shinyapps[86118]:     57: httr::oauth2.0_token
2016-03-19T23:18:49.649736+00:00 shinyapps[86118]: Stack trace (innermost first):
2016-03-19T23:18:49.573395+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573393+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.649749+00:00 shinyapps[86118]:     52: source
2016-03-19T23:18:49.649751+00:00 shinyapps[86118]:     12: fn
2016-03-19T23:18:49.649745+00:00 shinyapps[86118]:     56: drop_auth
2016-03-19T23:18:49.649753+00:00 shinyapps[86118]:     10: tryCatchOne
2016-03-19T23:18:49.649746+00:00 shinyapps[86118]:     55: eval [helper.R#11]
2016-03-19T23:18:49.649755+00:00 shinyapps[86118]:      8: tryCatch
2016-03-19T23:18:49.649756+00:00 shinyapps[86118]:      7: connect$retry
2016-03-19T23:18:49.649750+00:00 shinyapps[86118]:     13: runApp
2016-03-19T23:18:49.649747+00:00 shinyapps[86118]:     54: eval
2016-03-19T23:18:49.649748+00:00 shinyapps[86118]:     53: withVisible
2016-03-19T23:18:49.649762+00:00 shinyapps[86118]:      1: local
2016-03-19T23:18:49.649790+00:00 shinyapps[86118]: Error : oauth_listener() needs an interactive environment.
2016-03-19T23:18:49.649752+00:00 shinyapps[86118]:     11: doTryCatch
2016-03-19T23:18:49.649760+00:00 shinyapps[86118]:      3: eval
2016-03-19T23:18:49.649754+00:00 shinyapps[86118]:      9: tryCatchList
2016-03-19T23:18:49.649757+00:00 shinyapps[86118]:      6: eval
2016-03-19T23:18:49.649758+00:00 shinyapps[86118]:      5: eval
2016-03-19T23:18:49.649759+00:00 shinyapps[86118]:      4: eval
2016-03-19T23:18:49.649761+00:00 shinyapps[86118]:      2: eval.parent

This are the lines of code (on an already authenticated rdrop2 token) I try to run:

token <- readRDS('droptoken.rds')

list_files <- data.frame(name = gsub(".*\\/(.*)\\..*", "\\1", 
                                     drop_dir(drop_search('RData')[7,]$path)$path),
  path = drop_dir(drop_search('RData')[7,]$path)$path, 
  stringsAsFactors = FALSE)

As you can see, the token is already stored in the same folder with the .R files I am trying to run.

I am using the Publish to Server function in the RStudio IDE.

Running tests deletes ALL folders in users account

Just realized this happened from when I was running tests late the other night...seems like undesirable behavior. Too busy restoring all my stuff to dig into they "why" right now; will do so later. Thank goodness Dropbox doesn't perma-delete right away!

Revisions returned incorrectly

When testing the package, I am getting the following error:

Failed -------------------------------------------------------------------------
1. Failure: Revisions are returned correctly (@test-rdrop2.R#155) --------------
ncol(x) not equal to 14.
1/1 mismatches
[1] 15 - 14 == 1

Which is coming from these lines in the test-rdrop2.R file:

# drop_history

context("testing dropbox revisions")

test_that("Revisions are returned correctly", {
     skip_on_cran()
    write.csv(iris, file = "iris.csv")
    drop_upload("iris.csv")
    write.csv(iris[iris$Species == "setosa", ], file = "iris.csv")
    drop_upload("iris.csv")
    x <- drop_history("iris.csv")
    expect_equal(ncol(x), 14)
    expect_is(x, "data.frame")
    drop_delete("iris.csv")
    unlink("iris.csv")
})

Here is my session info:

> devtools::session_info("rdrop2")
Session info --------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.1 (2017-06-30)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.0.153)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/New_York            
 date     2017-09-12                  

Packages ------------------------------------------------------------------------------------------------------------
 package    * version  date       source         
 assertthat   0.2.0    2017-04-11 CRAN (R 3.4.0) 
 BH           1.62.0-1 2016-11-19 CRAN (R 3.4.0) 
 bindr        0.1      2016-11-13 CRAN (R 3.4.0) 
 bindrcpp     0.2      2017-06-17 CRAN (R 3.4.0) 
 curl         2.6      2017-04-27 CRAN (R 3.4.0) 
 data.table   1.10.4   2017-02-01 CRAN (R 3.4.0) 
 dplyr        0.7.2    2017-07-20 CRAN (R 3.4.1) 
 glue         1.1.1    2017-06-21 CRAN (R 3.4.1) 
 graphics   * 3.4.1    2017-07-07 local          
 grDevices  * 3.4.1    2017-07-07 local          
 httr         1.2.1    2016-07-03 CRAN (R 3.4.0) 
 jsonlite     1.5      2017-06-01 cran (@1.5)    
 magrittr     1.5      2014-11-22 CRAN (R 3.4.0) 
 methods    * 3.4.1    2017-07-07 local          
 mime         0.5      2016-07-07 CRAN (R 3.4.0) 
 openssl      0.9.6    2016-12-31 CRAN (R 3.4.0) 
 pkgconfig    2.0.1    2017-03-21 CRAN (R 3.4.0) 
 plogr        0.1-1    2016-09-24 CRAN (R 3.4.0) 
 R6           2.2.2    2017-06-17 cran (@2.2.2)  
 Rcpp         0.12.12  2017-07-15 cran (@0.12.12)
 rdrop2       0.7      2017-09-11 local          
 rlang        0.1.2    2017-08-09 cran (@0.1.2)  
 stats      * 3.4.1    2017-07-07 local          
 tibble       1.3.3    2017-05-28 cran (@1.3.3)  
 tools        3.4.1    2017-07-07 local          
 utils      * 3.4.1    2017-07-07 local   

Any idea as to how this failure could be produced?

This failure has been happening for around the last 8 months: https://travis-ci.org/karthik/rdrop2/builds/196017758#L1600

Add drop_exists

Various file operations (copy, move, delete, and history) will send a bad API call if the file/folder doesnt exist
Right now this isn't a problem because the API will return an error. But it seems like a better practice to catch this on the R side. So I'm considering writing drop_exists() which returns TRUE/FALSE. File operations should run this check before proceeding.

Provide more informative errors when oauth token not found

The common oauth_listener needs an interactive environement (e.g. #64) seems to often be due to .httr-auth not being where drop_auth expects it to be. This is a pretty unintuitive error message from httr; maybe we can wrap it a bit to let the user know we can't find the token?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.