• Stars
    star
    248
  • Rank 163,560 (Top 4 %)
  • Language
    R
  • License
    Other
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dropbox Interface from R

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.

More Repositories

1

wesanderson

A Wes Anderson color palette for R
R
1,766
star
2

markdown_science

Learn how to use markdown for science
TeX
300
star
3

holepunch

Make your R project Binder ready
R
249
star
4

rstudio2019

Resources from my Rstudio::conf 2019 talk
220
star
5

testdat

A package to run unit tests on tabular data
R
141
star
6

life-hacks

Some life hacks documented
97
star
7

smb_git

A review paper describing how git can be used to improve reproducibility in science
Shell
85
star
8

rDrop

Programmatic interface to Dropbox
R
64
star
9

dashboard

A R package dashboard generator
CSS
44
star
10

rdat

An R interface to data Dat
R
43
star
11

ddd

data, data, data paper
TeX
43
star
12

ggplot-lecture

My lecture on ggplot at Cal (spring 2013)
TeX
41
star
13

Rtools

Sublime text package for R
Python
33
star
14

zenodo

Deposit data (or any research object) into Zenodo
R
17
star
15

woRstfigures

woRst R figures
12
star
16

fujifilm

Just a collection of my notes on the Fujifilm X-T2 and X-mount ecosystem
12
star
17

randNames

Random username (+other useful info) generator
R
11
star
18

binder-test

R
11
star
19

git_intro

A quick introduction to git
CSS
10
star
20

sheetseeR

A quick and easy interface to Google Docs + SheetSee.js
R
9
star
21

dcTemplate

Data Carpentry R lesson template
HTML
7
star
22

mozfest-data-lessons

Repo for the data carpentry session at Mozfest
5
star
23

dlab-advanced-r

Repo with material on learning testing, documentation, and package development in R.
5
star
24

mapboxer

Mapbox from R
HTML
5
star
25

ggit

Git visualization tools for git2r
R
5
star
26

software-mapping-workshop

Slides, notes, and resources for the CZI Essentials of Open Source grantee meeting, December 9th, 2020
4
star
27

colorPalette

A colorPalette API for R
4
star
28

webnativesci

OKFestival session on tools and skills for web native science
JavaScript
4
star
29

sevilla15

Repo for workshop at Sevilla, February 2015
CSS
3
star
30

coyote

Functions from my .rprofile now moved to a package
R
3
star
31

esa_data_viz

ESA 2013, Data Visualization in R workshop
R
3
star
32

Rtools3

R tools for Sublime text 3
Python
3
star
33

stat290

R
2
star
34

bmc_post

Set of files for BMC blog post
2
star
35

rProvenance

A prototype for a provenance library implementation in R
R
2
star
36

gigadb

R
2
star
37

RRR

The reproducibility lexicon project at BIDS
Python
2
star
38

commcall

R
2
star
39

rthings

Provides short lists of fake data for use in examples and demos
R
2
star
40

tradeoff

revisiting classic life-history tradeoffs with realistic assumptions.
R
2
star
41

api-best-practices

plos comp bio paper draft
2
star
42

almviz

ALM Visualization from the PLOS Hackathon
CSS
2
star
43

badge-test

1
star
44

ecotools

Find out what tools other scientists use to stay productive
1
star
45

roweb-test

HTML
1
star
46

distill

HTML
1
star
47

2014-02-13-UNSW

Repository for the UNSW Software Carpentry Bootcamp
Python
1
star
48

karthikram.github.com

My Jekyll-Bootstrap github page
JavaScript
1
star
49

binder-test-docker-tidyverse

R
1
star
50

misc-scripts

Python
1
star
51

nick_dates

R
1
star
52

dygraph-test

R
1
star
53

themegray4lyfe

HTML
1
star
54

2014-10-31-nw

Repository for the NorthWestern University bootcamp
Perl
1
star
55

urssi_figures

Repository accompanying "A Survey of the State of the Practice for Research Software in the United States"
HTML
1
star
56

species_interactions

1
star
57

eeguide

A guide to using the ecoengine
CSS
1
star
58

R-Icon

An alternative icon for R.
1
star
59

demo

R
1
star
60

antweb_paper

Paper on AntWeb
TeX
1
star
61

sparse

TeX
1
star
62

write-with-make

A quick repo with an example of how to write with Makefiles
TeX
1
star
63

ucsf19

Notes and slides from my workshop on open code at UCSF
1
star
64

shiny

Short Shiny tutorial
R
1
star
65

DataCabin

1
star