Text manipulation in the `downloadHandler` filename?

I am new to shiny and I think I have a pretty simple question. I using a downloadHandler and I want to do some basic text manipulation to the filename. Can someone help me point out my error?

output$downloadbtn <- downloadHandler(
    filename = function() {
      return(paste(input$first, ".pdf", sep="")) # works correctly
    }
# ...

I instead would like to do something like which does not download correctly:

output$downloadbtn <- downloadHandler(
    filename = function() {
      first = str_to_lower(stri_trans_general(input$first))
      return(paste(first, ".pdf", sep="")) # does not work correctly
    }
# ...

I know I am almost certainly messing up something with the reactivity, but I'm not sure how I should go about fixing this issue. Any advice would be appreciated.

Hi,

I have not used the stri_trans_general function before, but reading its documentation you are missing the id parameter, I set it to "Latin-ASCII", but there's a long list you can choose from.

This works for me

stringr::str_to_lower(stringi::stri_trans_general("myFile", "Latin-ASCII"))

Hope this helps,
PJ

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.