1

* *連絡先 API の写真を変更したいのですが、例外が発生しました。コードを確認してください。

String filepath="C:\\Users\\bhanuprasad\\Documents\\Downloads\\549002_459129587462191_1689883124_n.jpg";
    File file = new File(filepath);

    byte[] photoData = new byte[(int) file.length()];
String url="https://www.google.com/m8/feeds/profiles/domain/"+ sDomain + "/full/pcvita1111qaeteam10?xoauth_requestor_id=appsadmin@soharcoas.com" ;
    ContactEntry profile = contactService.getEntry(
            new URL(url),ContactEntry.class);
 GDataRequest request = contactService.createRequest(GDataRequest.RequestType.UPDATE,
          photoUrl, new ContentType("image/jpeg"));

      request.setEtag(photoLink.getEtag());
    OutputStream requestStream = request.getRequestStream();
      requestStream.write(photoData);
     request.execute();

request.execute(); を呼び出すと、私は次の例外を得ました

com.google.gdata.util.InvalidEntryException: 不正なリクエスト無効な画像ファイル

at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:594)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)

私を助けてください....

4

1 に答える 1

0

実際に画像を読み取るコードはありません。ファイルの長さを使用してバイト配列を初期化するだけです。おそらく、初期化されていないファイルは有効なイメージではありません。実際の写真データをバイト配列に取得すると、機能するはずです。

于 2012-12-07T16:46:10.697 に答える