久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

上傳時EPIPE(斷管)?

EPIPE (Broken pipe) while uploading?(上傳時EPIPE(斷管)?)
本文介紹了上傳時EPIPE(斷管)?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的代碼有問題,但我不知道 E 日志報告在哪里

i have a problem in my code but i don't know where is it the E log report

04-08 05:47:46.745: E/Upload Server(20080): Starting  : /storage/sdcard1/Music/Piano (my favourites)/11 Tchaikovsky - The Music Lovers.mp3
04-08 05:47:47.136: E/Upload Server(20080): Connection Error : sendto failed: EPIPE (Broken pipe)

什么是(EPIPE)?,當我嘗試上傳圖像時,它的上傳成功,但任何其他文件 E Cat 報告(斷管)為什么!

what is (EPIPE) ? , when i attempt to upload image its upload successfully but any other file E Cat report (Broken pipe) why !

這是我的上傳代碼

   @Override
    protected String doInBackground(String... urls) {


    String upLoadServerUri = "http://test.com/test.php";
    String fileName = this.file_path;
    HttpURLConnection connection = null;
    DataOutputStream outputStream = null;
    String lineEnd = "
";
    String twoHyphens = "--";
    String boundary = "*****";
    int bytesRead, bytesAvailable, bufferSize;
    byte[] buffer;
    int maxBufferSize =  1*1024*1024;
    File sourceFile = new File(fileName);
    int sentBytes = 0;
    long fileSize = sourceFile.length();
    connection = null;


    try
    {


    FileInputStream fileInputStream = new FileInputStream(sourceFile);

    Log.e("Upload Server ", "Starting  : "+ fileName );

    URL url = new URL(upLoadServerUri);
    connection = (HttpURLConnection) url.openConnection();


    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setUseCaches(false);
    connection.setChunkedStreamingMode(1024);
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Connection", "Keep-Alive");
    connection.setRequestProperty("Content-Type","multipart/form-data;boundary="+boundary);
    outputStream = new DataOutputStream(connection.getOutputStream() );
    outputStream.writeBytes(twoHyphens + boundary + lineEnd);
    outputStream.writeBytes("Content-Disposition: form-data; name="file[]";filename=""+ fileName + """ + lineEnd);

       outputStream.writeBytes(lineEnd);
       bytesAvailable = fileInputStream.available();
       bufferSize = Math.min(bytesAvailable, maxBufferSize);
       buffer = new byte[bufferSize];



bytesRead = fileInputStream.read(buffer, 0, bufferSize);

   while (bytesRead > 0)
   {

   if(isCancelled()){

   break;
   }

   sentBytes += bytesRead;

   double percentDone = (sentBytes * 1.0) / fileSize * 100;
   publishProgress((int)percentDone);

   outputStream.write(buffer, 0, bufferSize);

   bytesAvailable = fileInputStream.available();

   bufferSize = Math.min(bytesAvailable,     maxBufferSize);
   bytesRead = fileInputStream.read(buffer, 0,      bufferSize);
   }

   if(isCancelled()){

    fileInputStream.close();
   outputStream.flush();
   outputStream.close();
   Log.e("Upload Server ", "upload Canceled " );
   return "canceled";
   }

   outputStream.writeBytes(lineEnd);
   outputStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
   int serverResponseCode       = connection.getResponseCode();
    fileInputStream.close();
   outputStream.flush();
   outputStream.close();

   if(serverResponseCode == 200)
   {
   Scanner s;
   s = new Scanner(connection.getInputStream());
   s.useDelimiter("\Z");
   final String response = s.next();
   Log.e("Upload Server ", "Message : " + response);
   return response;
   }else
   {
   Log.e("Upload Server ", "Server Code Error : " + serverResponseCode );
   return "faild";
   }
   }  catch (final Exception e) {

   Log.e("Upload Server ", "Error : " +  e.getMessage() );
   }

   return "falid";
}

請注意在 android 應用中瞄準仍然較新 :)我用谷歌搜索了我的問題,我找不到解決方案,請幫忙!

please note aim still newer in android apps :) i googled my problem i couldn't found a solution please help !

推薦答案

'Broken pipe' 表示你寫入的連接已經被對端關閉.

'Broken pipe' means you have written to a connection that has already been closed by the peer.

您可能已超出上傳大小限制.

Probably you have exceeded an upload size limit.

您還應該注意,您對 available() 的使用是無效的.Javadoc 中有一個關于 not 以您使用它的方式使用它的特定警告.反正你不需要它:

You should also note that your use of available() is invalid. There is a specific warning in the Javadoc about not using it the way you are using it. You don't need it anyway:

while ((count = in.read(buffer)) > 0)
{
  out.write(buffer, 0, count);
}

其中 buffer 是任何合理的大小,例如8192 字節.

where buffer is any reasonable size, e.g. 8192 bytes.

這篇關于上傳時EPIPE(斷管)?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 欧美日韩中文国产一区发布 | 国产成人精品一区二区 | 亚洲精品字幕 | 一区二区三区亚洲精品国 | 久久久久久久久国产精品 | 久久伊| 久久福利电影 | 97精品超碰一区二区三区 | 91精品国模一区二区三区 | 97色在线观看免费视频 | 免费看91| 欧美一区二区三区视频 | 亚洲免费片 | 精品欧美乱码久久久久久1区2区 | 中文字幕av一区二区三区 | 黄色片免费看 | 中文字幕第一页在线 | 亚洲午夜视频 | 成人在线免费观看 | 亚洲精品日本 | 美女视频h | 亚洲图片视频一区 | 91在线精品一区二区 | 亚洲综合首页 | 人和拘一级毛片c | 91成人在线视频 | 91在线精品秘密一区二区 | 午夜国产精品视频 | 亚洲一视频 | 亚洲第一av| 中文字幕男人的天堂 | 作爱视频免费看 | 黄色一级片在线播放 | 久久精彩视频 | 亚洲国产欧美一区二区三区久久 | 草草网| 伊人春色在线 | 国产精品一区二区av | 午夜看片网站 | 久久精品国产一区二区三区不卡 | 成人精品一区二区 |