【问题标题】:Unable to upload image to server using Ion library无法使用 Ion 库将图像上传到服务器
【发布时间】:2014-07-29 10:19:00
【问题描述】:

我正在使用 Ion 库将图像上传到 Web 服务器。但是当我尝试使用 setMultipartParamter 设置参数时,我得到空值。为什么会这样。

代码

 Ion.with(getActivity()).load("http://.......").setMultipartParameter("IUser_ID", "126").setMultipartParameter("&User_ID", "amody@gmail.com").setMultipartParameter("&FileTitle", strFileTitle).setMultipartParameter("&DT", strDocumentType).setMultipartFile("", new File(strFilePath)).asString().setCallback(new FutureCallback<String>() {
                        @Override
                        public void onCompleted(Exception e, String result) {
                            Log.e("Upload file response", "" + result);
                        }
                    });

我检查了服务器,文件上传正确但参数不正确。

【问题讨论】:

    标签: android android-ion


    【解决方案1】:

    您正在传递参数名称,就像它们是查询字符串一样。

    .setMultipartParameter("&User_ID", "amody@gmail.com")
    

    您不需要与号。您的服务器可能正在查看错误的密钥。

    【讨论】:

    • 是的,我尝试不使用 & 符号,但仍然出现错误
    • 错误---07-30 11:07:03.959 31229-31229/example.com.pocketdocs E/Response: System.NullReferenceException: 对象引用未设置为对象的实例。在 C:\APP\PocketDocs\PocketDocs\PocketDocsWeb\web\Account\UploadFile.aspx.vb 中的 Web_Account_UploadFile.Page_Load(Object sender, EventArgs e):第 19 行
    • 您的服务器代码中似乎有错误...我有单元测试来验证多部分表单上传是否适用于 App Engine 和 node.js 服务器。
    猜你喜欢
    • 1970-01-01
    • 2011-09-12
    • 1970-01-01
    • 1970-01-01
    • 2021-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多