bash curl PUT 数据来自一个大文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19261045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 08:13:58  来源:igfitidea点击:

curl PUT data from a huge file?

bashcurl

提问by Matti Virkkunen

I have some nasty curl with ntlm authentication and i need to PUT/send data from some file to server. This is how it looks like. My problem is how to change that data to be read from file easly?

我有一些带有 ntlm 身份验证的令人讨厌的 curl,我需要将数据从某个文件发送/发送到服务器。这是它的样子。我的问题是如何更改要从文件中轻松读取的数据?

I'm using bash there now.

我现在在那里使用 bash。

curl -v -X PUT http://server:port/databases/test/docs/testID -d "{ FirstName: 'Bob', LastName: 'Smith', Address: '5 Elm St' }" --ntlm --user 'username:pass'

I'm wondering how should i change that data in param -d with a file. Preferably not just echo-ed from certain path? I would rather use some option and just pass a file path

我想知道我应该如何使用文件更改 param -d 中的数据。最好不只是从某个路径回显?我宁愿使用一些选项并只传递一个文件路径

回答by Matti Virkkunen

You can use a file as data by passing -d @/path/to/file(or -d @-to read from stdin).

您可以通过传递-d @/path/to/file(或-d @-从标准输入读取)将文件用作数据。