如何使用cURL将文件内容作为主体实体发送 [英] How to send file contents as body entity using cURL

查看:80
本文介绍了如何使用cURL将文件内容作为主体实体发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cURL命令行实用程序将HTTP POST发送到Web服务。我想将文件的内容作为POST的主体实体。我已经尝试使用 -d< filename> 以及类型信息如 - data< filename> --data-urlencode< filename> 等...文件总是附加的。我需要它作为身体实体。

I am using cURL command line utility to send HTTP POST to a web service. I want to include a file's contents as the body entity of the POST. I have tried using -d <filename> as well as other variants with type info like --data <filename> --data-urlencode <filename> etc... the file is always attached. I need it as the body entity.

推荐答案

我相信你正在寻找 @filename 语法,例如:

I believe you're looking for the @filename syntax, e.g.:

curl --data "@/path/to/filename" http://...

这篇关于如何使用cURL将文件内容作为主体实体发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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