2012-03-01 5 views
2

Google App Engineデータストアに小さなTXTファイル(4KB)をアップロードしようとしています。私はlocalyアプリケーションをテストするときに問題はなく、ファイルは正常に保存されます。私はGAEにしようとするが、私は次のエラーを取得:javax.jdo.JDOException:文字列プロパティファイルが長すぎます。 1000000文字を超えることはできません

com.google.apphosting.api.ApiProxy$RequestTooLargeException: The request to API call datastore_v3.Put() was too large. 
at com.google.apphosting.runtime.ApiProxyImpl$AsyncApiFuture.success(ApiProxyImpl.java:480) 
at com.google.apphosting.runtime.ApiProxyImpl$AsyncApiFuture.success(ApiProxyImpl.java:380) 
at com.google.net.rpc3.client.RpcStub$RpcCallbackDispatcher$1.runInContext(RpcStub.java:746) 
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455) 
at com.google.tracing.TraceContext.runInContext(TraceContext.java:695) 
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333) 

ファイルが含まれているエンティティのJDOのマッピングは以下の通りです:GAEコンソールで

javax.jdo.JDOException: string property file is too long. It cannot exceed 1000000 characters. 
NestedThrowables: 
java.lang.IllegalArgumentException: string property file is too long. It cannot exceed 1000000 characters 

を、ログは以下の言いました:

@PersistenceCapable(identityType = IdentityType.APPLICATION) 
public class AppointmentEntity implements Serializable { 
    @PrimaryKey 
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
    private Long id;  
    @Persistent(serialized = "true") 
    private DownloadableFile file; 

そしてDownloadableFileは次のとおりです。

public class DownloadableFile implements Serializable { 
    private byte[] content; 
    private String filename; 
    private String mimeType; 

何が問題なの?私はセッションのサイズとエンティティのサイズについて何かを読んでいますが、ファイルサイズが小さいと私はこれらの理論を破棄します。

+0

データストアエンティティあたりの最大サイズは、[1メガバイト]です(http://code.google.com/appengine/ docs/python/datastore/overview.html#Datastore_Statistics)。あなたのテキストファイルがわずか4KBであることを見て、何とかそれをDSに何度も追加できますか?あなたが限界に打ち間違っている理由を説明するかもしれません。 –

+0

私はそうは思わない、更新は一度だけ実行されます。エンティティのサイズが1MBより大きい場合、ローカルデータストアは不平を言いますか? –

答えて

0

ブロブストアにあなたの小さなファイルを入れた後、データストアにblobKeyにを格納考えてみましょう:

@PersistenceCapable() 
public class FileEntity { 

    @PrimaryKey 
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
    protected Key key; 


    @Persistent 
    private BlobKey blobKey; 

} 




private void createBlobStoreEntity() throws IOException{ 
     final PersistenceManager pm = PMF.get().getPersistenceManager(); 
     final FileService fileService = FileServiceFactory.getFileService(); 
     final AppEngineFile file = fileService.createNewBlobFile(Const.CONTENT_TYPE_PLAIN); 
     final String path = file.getFullPath(); 
     final FileWriteChannel writeChannel = fileService.openWriteChannel(file, true); 
     PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8")); 
     try { 

      out.println(txt); 
      out.close(); 
      writeChannel.closeFinally(); 
      final BlobKey key = fileService.getBlobKey(file); 

      final ValueBlobStore store = new 
        FileEntity(key); 

      pm.makePersistent(store); 
      pm.flush(); 

     } 
     finally { 
      out.close(); 
      pm.close(); 
     } 
    } 
関連する問題