【发布时间】:2010-10-06 17:06:21
【问题描述】:
我正在尝试在 grails 中设置一个可以接受文件的 Web 服务。如何从请求中获取文件?
我正在用类似的东西测试这个
curl -d somefile.tar http://localhost:8080/MyWebS/fileWS
我的方法如下所示:
def index = {
switch(request.method){
case "POST":
render "Ingesting file\n"
request.each {
println("--> " + it)
}
def uploadedFile = request.getFile() //<--this is the line that doesnt work..what should it be?
File f=new File('c:/dev/newfile.tar');
uploadedFile.transferTo(f);
break
}
}
【问题讨论】:
-
它不是完全重复的。我正在尝试将其设置为使用 curl 进行测试