使用文件名中的分号卷曲文件上传 [英] curl file upload with semicolons in filename

查看:122
本文介绍了使用文件名中的分号卷曲文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用curl到servlet来实现自动化的命令行文件上传器。

I'm implementing an automated, command line file uploader using curl to a servlet.

问题是,我有成千上万个带有分号的文件(;)中的文件名。我对此很烦恼,但这是一个旧版应用,每天仍在继续产生新文件。由于下游的兼容性原因,重命名并不是真正的选择。

The problem is, I've got tens of thousands of files with semicolons (;) in the filenames. I'm well aware of the annoyance of this but it is a legacy app that continues to produce new files each day. Renaming is not really an option for compatibility reasons downstream.

我尝试引用,转义,转换为%3b,完全限定路径...显而易见东西...但是似乎没有任何作用,并且无法从客户端发送。我正在使用Mac(捆绑的curl版本7.21.3),但这不应该有所作为吗?

I've tried quoting, escaping, converting to "%3b", fully qualifying the path... the obvious stuff... but nothing seems to work, and it fails to send from the client side. I'm on my mac (bundled curl version 7.21.3) but that shouldn't make a difference?

有什么想法吗?

macbookpro:~$ curl -F upload=@"my file.txt" http://localhost:8080/data/upload
ok
macbookpro:~$ curl -F upload=@"my;file.txt" http://localhost:8080/data/upload
curl: (26) failed creating formpost data
macbookpro:~$ curl -F upload=@"my\;file.txt" http://localhost:8080/data/upload
curl: (26) failed creating formpost data
macbookpro:~$ curl -F upload=@"my\\;file.txt" http://localhost:8080/data/upload
curl: (26) failed creating formpost data
macbookpro:~$ 


推荐答案

curl 使用; 可以将类型(或其他指令)与实际名称分开,所以我只是使用stdin代替:

curl uses ; to separate type (or other directives) from the actual name, so I'd simply use stdin instead:

cat 'my;file.txt' | curl -F upload=@- http://localhost:8080/data/upload

您可能如果需要,还可以添加 filename = 指令(但名称中不能使用分号!)。

You may possibly add filename= directive as well if desired (but without the semicolon in the name!).

这篇关于使用文件名中的分号卷曲文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆