I can run this command in my bash shell. The command makes a request to an API to compress an image, and gets a response from the API without issue:
curl https://my.api.com --user api:mypassword --data-binary @/Users/myUsername/MyDirectoryName\ \(abc\)/test/my/file.png --dump-header /dev/stdout
Within an R script, when I try to run the same command within R's system
(docs), like this:
system("curl https://my.api.com --user api:mypassword --data-binary @/Users/myUsername/MyDirectoryName\ \(abc\)/test/my/file.png --dump-header /dev/stdout", intern = T)
I get an error message:
Error: '\(' is an unrecognized escape in character string starting "curl https://my.api.com --user api:mypassword --data-binary @/Users/myUsername/MyDirectoryName\ \("
I do not have control over the directory name, with its whitespace and special characters, e.g. (
and )
.
How do I need to change the command string passed to system
? If this is a character escaping issue as I think it is, how would I perform the escape?
Thank you