googleAnalyticsR
googleAnalyticsR copied to clipboard
Data upload with no filename
Apparently its an error with client libraries so why does it happen here too?
http://stackoverflow.com/questions/39537395/file-name-in-uploaddata-google-analytics
Hi Mark. I just solved this by uploading files using Curl. The filename need to be specified in Json format. Do you need help?
Help appreciated, have you an example? The function is here https://github.com/MarkEdmondson1234/googleAnalyticsR/blob/master/R/custom_data_source.R#L229
The trick is in the metadata var.
library('jsonlite')
metadata <- tempfile()
writeLines(jsonlite::toJSON(list(title = unbox("ga_uploads/refunds.csv"))), metadata)
data <- POST(gaEndPoint,
body = list(
metadata = upload_file(metadata, type = "application/json; charset=UTF-8"),
media = upload_file('ga_uploads/refunds.csv', "application/octet-stream")
),
add_headers("Content-Type" = "multipart/related"),
config(token = token),
encode = "multipart",
verbose())
stop_for_status(data)
I need to test this, but should be fixed.