从Android相机上传的grails文件不起作用

时间:2013-02-12 10:10:51

标签: android grails file-upload

我正在尝试用grails创建一个文件上传器。如果照片是从“驱动器”拍摄的,我也可以从android上工作,但我不能让它工作它是“从相机中活着”

这是页面“:

中的表格
<form target="[...]" enctype="multipart/form-data" method="post" action="fileUpload">
<input accept="image/*" name="upload" type="file"/>  
</form>

这是grails中的控制器

println "FileUploadController.index.params: " + params
CommonsMultipartFile file = request.getFile('upload')
println "file.class: " + file.class
println "filename:" + file.getOriginalFilename()
println "file.contentType: " + file.contentType
println "file.empty: " + file.empty
println "file.size: " + file.size
println "file.fileItem.class: " + file.fileItem.class
println "file.fileItem:" + file.fileItem
println "file.fileItem.name: " + file.fileItem.name
[...]

当我尝试上传从已拍摄的图像中挑选的文件时,一切正常,println有此输出

file.class: class org.springframework.web.multipart.commons.CommonsMultipartFile
filename:IMAG0003.jpg
file.contentType: image/jpeg
file.empty: false
file.size: 1473097
file.fileItem.class: class org.apache.commons.fileupload.disk.DiskFileItem
file.fileItem:name=IMAG0003.jpg, StoreLocation=D:\cpsfm\stuff\HelpDeskGwt\branches\sviluppo\target\.grails\tomcat\work\Tomcat\localhost\HelpDeskGwt\upload_73dcfe52_13ccdd4635a__8000_00000001.tmp, size=1473097bytes, isFormField=false, FieldName=upload
file.fileItem.name: IMAG0003.jpg

然后控制器保存文件......

但如果我尝试用相机拍照,控制器就会输出

file.class: class org.springframework.web.multipart.commons.CommonsMultipartFile
filename:
file.contentType: null
file.empty: true
file.size: 0
file.fileItem.class: class org.apache.commons.fileupload.disk.DiskFileItem
file.fileItem:name=, StoreLocation=D:\cpsfm\stuff\HelpDeskGwt\branches\sviluppo\target\.grails\tomcat\work\Tomcat\localhost\HelpDeskGwt\upload_73dcfe52_13ccdd4635a__8000_00000003.tmp, size=0bytes, isFormField=false, FieldName=upload
file.fileItem.name: 

因此控制器无法保存文件... 为什么grails不能识别相机拍摄的照片?或者为什么android没有将图片发送到服务器?

0 个答案:

没有答案