草庐IT

FileBody

全部标签

android - 在 MultipartEntity 中使用 FileBody 进行 UTF-8 编码

我想像在StringBuilder中那样在FileBody中发送文件时设置UTF-8编码。我这样做:restClient.AddEntity("body",newStringBody(body,Charset.forName("UTF-8")));如果我发送的消息编码与UTF-8不同,它也能正常工作。但如果我这样做:ContentBodyfbody=newFileBody((File)file,"application/octet-stream","UTF-8");restClient.AddEntity("files[]",fbody);服务器获取非UTF-8格式的文件名。我该如何解

android - ByteArrayOutputStream 到 FileBody

我有一个图像的Uri,该图像是从图库中拍摄或选择的,我想将其加载并压缩为质量为75%的JPEG。我相信我已经通过以下代码实现了这一目标:ByteArrayOutputStreambos=newByteArrayOutputStream();Bitmapbm=BitmapFactory.decodeFile(imageUri.getPath());bm.compress(CompressFormat.JPEG,60,bos);并不是说我已经将它塞进了一个名为bos的ByteArrayOutputStream中,然后我需要将它添加到一个MultipartEntity中以便HTTPPOST到

java - 找不到类 'org.apache.http.entity.mime.content.Filebody',从方法中引用

我想做的是将图片发送到网络服务器。当我在我的Android项目中调用方法时,出现以下错误:找不到类“org.apache.http.entity.mime.content.Filebody”,引用自方法com.example.tc.Send.send。即使我有以下导入,也会发生这种情况:importorg.apache.http.HttpEntity;importorg.apache.http.HttpResponse;importorg.apache.http.client.HttpClient;importorg.apache.http.client.methods.HttpPos