r - 通过 R 管道工 api 上传文件不起作用
问题描述
我正在尝试使用管道工 api 上传 json 文件,但在 Postman 中进行测试时,我得到“405 - 方法不允许”。
使用的代码
# plumber.R
#* Echo the parameter that was sent in
#* @get /echo
function(){
list(msg = 'Hello World')
}
#* Model
#* @param upload File to upload
#* @post /uploadfile
function(req, res){
fileInfo <- list(formContents = Rook::Multipart$parse(req))
## The file is downloaded in a temporary folder
tmpfile <- fileInfo$formContents$upload$tempfile
## Copy the file to a new folder, with its original name
fn <- file.path(fileInfo$formContents$upload$filename)
file.copy(tmpfile, fn)
## Send a message with the location of the file
res$body <- paste0("Your file is now stored in ", fn, "\n")
res
}
使用以下 curl 命令上传文件
curl -v -F upload=@"D:\projects\notes1.txt" http://localhost:4535/uploadfile
邮递员错误
解决方案
推荐阅读
- pyspark - 即使路径中同时存在 mssql.jar 和 .dll,Spark 也无法找到 SQL Server jdbc 驱动程序
- apache-spark - Spark Structured Streaming 基于时间戳的窗口聚合输出 - 为什么不按时间排序?
- flutter - 在颤振代码中从 Firebase 检索 table_calendar 事件
- powershell - 如何使用 Powershell 递归重命名目录中的文件?
- sapui5 - 当显示隐藏的输入字段时,UI5 对话框会增加其大小
- javascript - 为什么我的 mysql 数据库连接不起作用?
- android - 在我的情况下,如何修复“无法从当前目的地目的地找到导航操作/目的地”错误?
- c# - 防止 ScrollViewer 更改其内容大小
- azure-active-directory - 针对特定用户角色的 Microsoft OAuth 授权
- python - 使用python打开/读取带有颜色的rw2图像?