4

コードに問題がありますが、E ログ レポートの場所がわかりません

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)

(エピペ)とは?、画像をアップロードしようとすると、アップロードは成功しましたが、他のファイル E Cat レポート (壊れたパイプ) なぜ !

これは私のアップロードコードです

   @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 = "\r\n";
    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アプリではまだ新しいことを目指していることに注意してください:)私は自分の問題をグーグルで検索しましたが、解決策が見つかりませんでした助けてください!

4

2 に答える 2