#' Allows you to upload multiple files to a given survey
#'
#'
#' @param Upload_Table A data.table with the relevant information in the columns listed below
#' Upload_Table has the following columns:
#' sid
#' field_name
#' file_name
#' @param Folder_Location_Files Where are the files saved? Just the name of the folder as a string
#' @export
#' @examples \dontrun{
#' Import_Questions(Upload_Table, Folder_Location_Files = "Upload_Files")
#' }
#'
Upload_Files <- function(Upload_Table, Folder_Location_Files = "Upload_Files"){
get_session_key() # Log in
if(is.na(Folder_Location_Files)){
Files_Top_Folder <- ""
}
else{
Files_Top_Folder <- paste0(Folder_Location_Files, "/")
}
results <- list()
for(i in 1:nrow(Upload_Table)){
file <- read_file(paste0(Files_Top_Folder, Upload_Table[i]$file_name))
file <- base64_enc(file)
results[[paste0(Upload_Table[i]$sid,"X",Upload_Table[i]$file_name)]] <- call_limer(method = "import_question",
params = list(iSurveyID = Upload_Table[i]$sid,
sFieldName = Upload_Table[i]$field_name,
sFileName = Upload_Table[i]$file_name,
sFileContent = file
))
}# end for loop
return(results)
} # end function
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.