- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我一直在尝试将图像和数据上传到 Django 服务器。我包含了 apache-mime4j.0.6.jar
和 httpmime4.0.1.jar
库(Project->build path->Add external jar files)这是上传图片的代码。
HttpResponse response = null;
try {
HttpPost httppost = new HttpPost("http://10.0.2.2:8000/mobile");
// HttpPost httppost = new HttpPost("some url");
MultipartEntity multipartEntity = new MultipartEntity(); //MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
multipartEntity.addPart("name", new StringBody("nameText"));
multipartEntity.addPart("place", new StringBody("placeText"));
multipartEntity.addPart("tag", new StringBody("tagText"));
//multipartEntity.addPart("Description", new StringBody(Settings.SHARE.TEXT));
multipartEntity.addPart("Image", new FileBody(destination));
httppost.setEntity(multipartEntity);
httpclient.execute(httppost, new PhotoUploadResponseHandler());
} catch (Exception e) {
Log.e( "Error","error");
}
错误信息:
Could not find class 'org.apache.http.entity.mime.MultipartEntity'
而且我尝试手动创建 libs 文件夹并将 jar 文件手动包含到/libs 文件夹中。当我这样做时,它无法编译。
错误:
Conversion to Dalvik format failed with error 1 Unknown Android Packaging Problem
尝试创建包括库在内的全新应用程序。我遇到了同样的错误。我已经尝试了所有可能的方法。任何人都可以告诉我为什么会发生这种情况以及如何解决它。任何帮助将不胜感激!!
最佳答案
如果你正在使用新的 android-sdk
试试这个。
libs
的文件夹就是这样。这可能会有所帮助。祝你好运。
关于Android 使用 MultipartEntity 将图像发布到服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13190009/
可能这是一个重复的问题,但我已经尝试过该网站的所有答案,但都不起作用! 我正在使用 MultipartEntity 进行图像上传。它在模拟器中工作得很好,但是当我 checkin 设备时它不工作。 在
所以我创建了一个 Workout 类,我想使用 HttpPost 将它发送到服务器。有什么方法可以将该类添加到 MultipartEntity 中,或者我应该如何发布它? 最佳答案 首先,您的类必须实
我想使用 MultipartEntity 上传图片。我尝试了以下代码。 我没有收到任何错误,但图片未上传。我有足够的上传权限 PHP 'success', 'm
在我开始之前,我看到了很多关于这个的问题,但对我来说没有任何用处也许有人可以向我解释或向我展示如何将位图压缩为 MultiPart 实体,然后使用 Retrofit 将其正确发送到服务器 最佳答案 对
不确定为什么会这样,但这行代码使我的应用程序在调试或运行模式下崩溃: MultipartEntity multipartEntity = new MultipartEntity(HttpMultipa
我最近将我的项目从 Eclipse 迁移到 Android Studio(我还没有完全控制这个 IDE)。在这个项目中,我有一个文件 uploader AsyncTask,它通过 http 发送多部分
文档说 org.apache.http.entity.mime.MultipartEntity类已弃用。有人可以给我推荐一个替代方案吗? 我在我的代码中这样使用它: entity.addPart("p
我想使用 MultipartEntity 上传单张图片。我尝试了以下代码。 但是图片没有上传。我没有收到任何错误。我已经为此添加了足够的库 try { HttpClient
这是我目前所拥有的: MultipartEntity reqEntity = new MultipartEntity(); String strXMLFilename = "/sdcard/image
我想使用 MultipartEntity 将图像和 JsonObject 发送到 PHP 服务器。这是我的代码: HttpClient httpClient = new DefaultHttpClie
我正在使用 MultiPartEntity 在我的 Android 应用程序中发布 XML + 图片,一切都很好,除了我要发布到的服务器要求我设置 Content- HTTP post 的类型到app
我在 MultipartEntity 中传递 3 张图像。这很好用,但我不知道如何将 String 值传递给 MultipartEntity。以下是我的代码: public void executeM
我一直在尝试将图像和数据上传到 Django 服务器。我包含了 apache-mime4j.0.6.jar 和 httpmime4.0.1.jar 库(Project->build path->Add
我想将文件的内容作为 org.apache.http.entity.mime.MultipartEntity 发送。问题是,我实际上没有文件,只有 String 形式的内容。以下测试完美运行,其中 f
如何执行此代码以便它在后台线程中发送? // TODO: Send image in background HttpClient httpclient = new Defaul
我需要将其解析为 JsonArray 而不是对象但它似乎无法正常工作。 my output is ["{"TransactionVolume":"34","TransactionitemID":"2"
我想在我的 AndroidHttpClient 中实现一个 ProgressDialog。我在这里找到了一个简单的实现 CountingMultipartEntity . 另外我添加了内容长度支持。我
我尝试在 Android 中使用 MultiPartEntity 和 HttpClient 发送图像,但不断收到异常:java.lang.UnsupportedOperationException:
我正在尝试使用 HttpClient 和 MultipartEntity 将图像从 Adroid 应用程序上传到 php 网络服务器。 这是我的代码 fragment : protected Void
我现在有一个 Tomcat 实例,它接受上传并对数据进行一些处理工作。 我想用符合类似 API 的新 servlet 替换它。首先,我希望这个新 servlet 将所有请求代理到旧的 servlet。
我是一名优秀的程序员,十分优秀!