2016-12-23 6 views
0

私のアプリでは、サーバーの緯度、経度、および画像に3つのパラメータを送信しています。以前はパラメータを送信するためにvolleyを使用していましたが、私のコードでマルチパート。しかし、私はuploadind中にエラーを取得しています。通知バーでアップロードが開始されますが、いくつかの時間後には、以下
のアップロード中にエラーがマルチパートのコードで書かれています:アップロード中のエラー

以下
public void send() { 
      try { 
       String uploadId = UUID.randomUUID().toString(); 


       //Creating a multi part request 
       new MultipartUploadRequest(this, uploadId, REGISTER_URL) 
         .setMethod("POST") 
         .addParameter("action", "location") 
         .addFileToUpload(imagePath, "data")//Adding file 
         //.addParameter("name", name) //Adding text parameter to the request 
         .setNotificationConfig(new UploadNotificationConfig()) 
         .setMaxRetries(5) 
         .startUpload(); //Starting the upload 

      } catch (Exception exc) { 
       Toast.makeText(this, exc.getMessage(), Toast.LENGTH_SHORT).show(); 
      } 
     } 

は私のボレーコードです:

final String latitudee = String.valueOf(latitude); 
    final String longitudee =String.valueOf(longitude); 
    final String datae = imagePath; 
    //getting the actual path of the image 

    StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, 
      new Response.Listener<String>() { 
       @Override 
       public void onResponse(String response) { 
        Toast.makeText(MapsActivity.this,response,Toast.LENGTH_LONG).show(); 
        System.out.println(response); 
       } 
      }, 
      new Response.ErrorListener() { 
       @Override 
       public void onErrorResponse(VolleyError error) { 
        Toast.makeText(MapsActivity.this,error.toString(),Toast.LENGTH_LONG).show(); 
       } 
      }){ 
     @Override 
     protected Map<String,String> getParams(){ 
      Map<String,String> params = new HashMap<String, String>(); 
      params.put("action","location"); 
      params.put("latitude",latitudee); 
      params.put("longitude",longitudee); 
      send(); 
      // params.put("data", datae); 
      //Uploading code 




      return params;} 
    }; 

    RequestQueue requestQueue = Volley.newRequestQueue(this); 
    requestQueue.add(stringRequest); 
} 

どこで私を助けてください間違っている

答えて

0

他のパラメータもMultipartリクエストライブラリから送信できます。より多くのパラメータを送信するには、単に "add parameter"を追加してください。

関連する問題