将curl命令翻译成java/android
有人可以帮我弄清楚如何将以下curl命令转换为Java语法以便在Android应用程序中使用吗?
curl 命令为:
curl -u 用户名:密码 -H "Content-Type:application/vnd.org.snia.cdmi.container" http://localhost:8080/user
curl -u 用户名:密码 -T /home/user1/a.jpg -H "内容类型:图像" http://localhost:8080/user/a.jpg
谢谢
Can someone help me figure out how to translate the following curl commands into Java syntax for use in an Android application?
The curl commands are:
curl -u username:password -H "Content-Type:application/vnd.org.snia.cdmi.container" http://localhost:8080/user
curl -u username:password -T /home/user1/a.jpg -H "Content-Type:image" http://localhost:8080/user/a.jpg
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 Android 中使用 Apache HttpClient 来执行 HTTP 发布。
HttpClient 代码片段(未经测试)
}
检查以下链接中的基本身份验证部分(您的 -u 选项)
http://dlinsin.blogspot.com/ 2009/08/http-basic-authentication-with-android.html
如何使用与 PHP 配合使用的 Java HttpClient 库上传文件
You can use Apache HttpClient in Android for performing HTTP posts.
HttpClient code snippet (untested)
}
Check the following link for the basic authentication part (your -u option)
http://dlinsin.blogspot.com/2009/08/http-basic-authentication-with-android.html
How to upload a file using Java HttpClient library working with PHP