0

私が現在使用しているコードに従ってください。サーバーに送信することはできますが、エンコードされた文字列をデータバイトに変換できないため、画像をデータベースに blob として挿入できません。これどうやってするの ?

private void restWebServicesCall_updateJobDetail(String strScheduleGUID) {
    System.out.println("Inside od job info");
    HttpClient httpClient = new DefaultHttpClient();

    img_Sign.buildDrawingCache();
    Bitmap bm = img_Sign.getDrawingCache();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();  
    bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bm is the bitmap object   
    byte[] b = baos.toByteArray();

    String encodedImage = Base64.encodeToString(b , Base64.DEFAULT);


    try {
        JSONObject c = new JSONObject();
        // c.put("JobRef", strJobRef);
        c.put("ScheduleGUID", strScheduleGUID);
        c.put("OutcomeCode", "ACH");
        c.put("Report", txt_ReportedProblem.getText().toString().trim());
        c.put("Signee", edt_CustomerName.getText().toString().trim());
        c.put("ActDetails", "FixedEEE");
        c.put("StartDate", "2013-09-12 09:00:00");
        c.put("EndDate", "2013-09-15 17:00:00");
        c.put("Signature", encodedImage);

        System.out.println("Cc value : " + c.toString());
        StringEntity sendStuff = new StringEntity(c.toString());
        HttpPost omidPost = new HttpPost("web address");
        omidPost.setHeader("Accept", "*/*");
        omidPost.setHeader("Content-type", "application/json");
        omidPost.setHeader("Accept-Encoding", "gzip");
        omidPost.setHeader("Accept-Language", "en-US,en;q=0.8");
        omidPost.setEntity(sendStuff);
        HttpResponse postResponse = httpClient.execute(omidPost);
        String postText = EntityUtils.toString(postResponse.getEntity());
        Log.d("omid debug", "rest post response was " + postText);
        getJSON_Response(postText);
    } catch (IOException e) {
        e.printStackTrace();
        System.out.println("Error : " + e.toString());
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        System.out.println("Jsone Error : " + e.toString());
    }
}
4

0 に答える 0