r - 手机上 ggplot2 的闪亮下载按钮
问题描述
我在移动设备 (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()
}
)
这是用户界面代码:
downloadButton(outputId = "npsDown", label = "Download Chart")
当我单击桌面上的下载按钮时,情节下载完美。但是当我尝试在移动设备(iOS)上执行此操作时,会发生这种情况:来自下载的奇怪代码
解决方案
您应该将添加添加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'
)
推荐阅读
- html - 如何在保持相同视觉外观的同时减少 CSS 文件中的行数(CSS 代码优化)
- json - 我如何仅在特定时间允许 aws IAM 权限
- python - 如何创建网格的新实例,用实体填充该网格并返回该网格
- date - 如何判断月份是否在两个日期之间?
- java - 如何有效地减少必须检查所有可能组合排列的项目集合?
- java - 按下按钮时尝试执行操作
- python - 即使我是一个 if 语句告诉不要,我的循环也会遇到负数
- python - 为新记录创建自定义唯一 ID 但有重复错误
- marklogic-dhf - 无法通过 REST Api 运行摄取
- amazon-web-services - 为什么 S3 对象的 ETag 在副本下会发生变化?