Last active
June 21, 2019 13:24
-
-
Save cecilialee/7d7e7e6517c0c2c1b3a37b4b72854e8c to your computer and use it in GitHub Desktop.
Read and write pdf to MongoDB with mongolite in R #r #mongolite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(mongolite) | |
# MongoDB connection | |
m <- mongo("listcopro") | |
# Read raw data | |
file <- file("/Users/cecilialee/Dropbox/dropbox/freelance/listcopro/bitbucket/recruitment/test/data/resume_1.pdf", "rb") | |
data <- readBin(file, "raw", 9999999) | |
# Save to database | |
m$insert(list(id = "01", cv = data)) | |
# Retrieve the inserted cv | |
cv <- as.raw(m$find('{"id":"01"}')$cv[[1]]) | |
# Output cv | |
writeBin(cv, "resume_1_mongo.pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment