我在移动版(iOS)上使用downloadButton遇到问题,但在台式机上没有问题。这是服务器代码:
output$npsDown <- downloadHandler(
filename = function() {
paste("BL", npsPlayerID(), "S", sep="")
},
content = function(file) {
#PLOT STUFF HERE
ggsave(file, plot = plot, device = "jpeg")
dev.off()
}
)
这是UI代码:
downloadButton(outputId = "npsDown", label = "Download Chart")
当我单击桌面上的下载按钮时,该图将完美下载。但是,当我尝试在移动设备(iOS)上进行操作时,会发生这种情况:weird code from download
答案 0 :(得分:1)
您应将添加的contentType = 'image/png'
添加到downloadHandler
中。
output$npsDown <- downloadHandler(
filename = function() {
paste("BL", npsPlayerID(), "S", sep="")
},
content = function(file) {
#PLOT STUFF HERE
ggsave(file, plot = plot, device = "jpeg")
dev.off()
},
contentType = 'image/png'
)