ファイルAPIが廃止ですが、GCSへの切り替えができません。困っています。

184 views
Skip to first unread message

青山鳩太郎

unread,
Sep 3, 2015, 4:22:36 AM9/3/15
to Google-App-Engine-Japan
9/5でGAEのファイルAPIが使用できなくなます。
そこで、GCSへ切り替えていますが、上手くいきません。
コンパイルエラーとなります。
GcsFileOptions.Builder() で以下のコンパイルエラーになります。
The type com.google.common.collect.ImmutableMap$Builder cannot be resolved. 
It is indirectly referenced from required .class files
ビルドパスを色々入れ替えましたが上手くいきません。
9/5で廃止となります。何とかヒントを下さい。

(参考)当該処理は、画像をGCSへ保存している処理となります。
public static BlobKey uploadFile(
String companyCode,
       String fileName, String mimetype, byte[] data)
        throws IOException  {
//FileAPIが廃止となり、GCSを使う 2015/09/03
       String bucketName = "locguide";
       String objectName = companyCode + "_" + randomNumAllString(32);
       
       GcsService gcsService = null;
       GcsFilename gcsFilename = null;
       GcsFileOptions options = null;
       GcsOutputChannel writeChannel = null;
       
       gcsService = GcsServiceFactory.createGcsService();
       gcsFilename = new GcsFilename(bucketName, objectName);
       String a = mimetype;
       try {
        options = new GcsFileOptions.Builder()   ← コンパイルエラー???
                                  .acl("private") .mimeType(mimetype)
         .build();
           writeChannel = gcsService.createOrReplace(gcsFilename, options);
           writeChannel.write(ByteBuffer.wrap(data));
       
       } catch (IOException exception) {
           outputErrorLog(exception);
       } finally {
           try {
               writeChannel.close();
           } catch( IOException e) {
               outputErrorLog(e);
           }
       }
       // BlobKeyを作成
       //AwohatoLog.outputLog("/gs/" + bucketName + "/" + objectName);
       BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
       BlobKey blobKey = blobstoreService.createGsBlobKey("/gs/" + bucketName + "/" + objectName);
       return blobKey;
       
   }



Teruhisa Narita

unread,
Sep 4, 2015, 3:44:42 AM9/4/15
to Google-App-Engine-Japan
おそらくguava-15.0.jarをダウンロードしてクラスパスに追加すれば直るのではないでしょうか。(最新版のguava.jarだと互換性の問題かエラーが出たような記憶があります)

以下のURLからダウンロードできます。


2015年9月3日木曜日 17時22分36秒 UTC+9 青山鳩太郎:

青山鳩太郎

unread,
Sep 6, 2015, 10:23:43 PM9/6/15
to Google-App-Engine-Japan
ありがとうございます。

> おそらくguava-15.0.jarをダウンロードしてクラスパスに追加すれば直るのではないでしょうか。

早速、試してみます。


Reply all
Reply to author
Forward
0 new messages