gpt4 book ai didi

android - 非法状态异常 : Content has been consumed

转载 作者:太空狗 更新时间:2023-10-29 16:24:20 26 4
gpt4 key购买 nike

class VideoUploadTask extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... unsued) {
try {
Log.i("VideoUploadTask", "enters");

HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(
"http://192.168.5.10/ijoomer_development/index.php?option=com_ijoomer&plg_name=jomsocial&pview=album&ptask=upload_video&session_id="+ConstantData.session_id +"");
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// bitmap.compress(CompressFormat.JPEG, 100, bos);
byte[] data = bos.toByteArray();
Log.i("categoryId in vedio upload2", ""+ConstantData.categoryId);
entity.addPart("categoryId", new StringBody(ConstantData.categoryId.toString()));
entity.addPart("video", new ByteArrayBody(data, "myvideo.mp4"));
/*
* entity.addPart("photoCaption", new
* StringBody(caption.getText() .toString()));
*/
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost,localContext);
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(
response.getEntity().getContent(), "UTF-8"));

String sResponse = reader.readLine();

String strResponse = convertStreamToString(in);
System.out.println(strResponse);
if (dialog.isShowing())
dialog.dismiss();

return strResponse;

} catch (Exception e) {
if (dialog.isShowing())
dialog.dismiss();
// Toast.makeText(getApplicationContext(),"Exception Image",Toast.LENGTH_LONG).show();
Log.e(e.getClass().getName(), e.getMessage(), e);
return null;
}

// (null);
}

在日志 cat 中出现错误 IllegalStateException: Content has been consumed。我找不到什么问题。请帮助我更正此错误。

解决IllegalStateException: Content has been consumed问题。但是通过这种编码我无法上传视频。请给我一些建议。

最佳答案

你调用了 getContent() 两次:

            InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(
response.getEntity().getContent(), "UTF-8"));

使用 in 创建阅读器。

关于android - 非法状态异常 : Content has been consumed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5906890/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com