drop_content_hash: Compute Dropbox's content hash for one or more files

View source: R/drop_content_hash.R

drop_content_hashR Documentation

Compute Dropbox's content hash for one or more files

Description

Compute a "content hash" using the same algorithm as dropbox. This can be used to verify the content against the content_hash field returned in drop_dir.

Usage

drop_content_hash(file)

Arguments

file

A vector of filenames

Details

Dropbox returns a hash of file contents in drop_dir. However, this is not a straightforward file hash. Instead the file is divided into 4MB chunks, each of those is hashed and then the concatenation of the hashes is itself hashed (see this page in the dropbox developer documentation for the details). It's entirely unclear why it does not compute a hash of the file itself, but here we are.

Value

A character vector the same length as file. Each element is 64 character string which is the unique hash. Two files that have the same hash have the same contents. Compare this hash of a local file with the content_hash field from drop_dir to see if you have the same file as dropbox.

Examples

## Not run: 
write.csv(mtcars, file = "mtt.csv")
drop_upload("mtt.csv")
files <- drop_dir()
# Dropbox's reported hash
files$content_hash[files$name == "mtt.csv"]
# Our computed hash:
drop_content_hash("mtt.csv")

## End(Not run)

karthik/rdrop2 documentation built on March 28, 2024, 5:51 a.m.