Awesome reprex!! Thank you!! That made my life so much easier And now we get a functional example!! (I think). I have to admit my testing is pretty minimal. I think we're super close though! This is exciting stuff!
You were trying to write a vector to the database, and RPostgres was complaining. Postgres wants a string representation of the hex (prefixed with
\x), which I just did with a little
paste(..., collapse = ""). I'm sure there are other ways to marshal all of this w/ string manipulation, hex / binary conversion, etc. It looks like it's working though!!
con <- dbConnect(RPostgres::Postgres(),host="localhost",
writeBin(z$fileRaw,'test_output.txt') #confirm identical file can be created
#>  61 2c 62 2c 63 0a 64 2c 65 2c 66 0a
"INSERT INTO file_upload (file_name,file_type,report_id,file) VALUES ( $1,$2,
list(my_file_name,my_file_type,my_report_id,paste0("\\x", paste(my_file, collapse = "")))
get_res <- dbGetQuery(con, "SELECT * from file_upload")
#>  TRUE
Created on 2019-04-22 by the reprex package (v0.2.1)