GoogleAppEngineでBLOBを保存して提供しようとしています。
// Save the data as a blob
final FileService fileService = FileServiceFactory.getFileService();
final AppEngineFile file = fileService.createNewBlobFile("application/zip", "nameOfSavedFile");
final FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
writeChannel.write(ByteBuffer.wrap(data));
writeChannel.closeFinally();
// Load the blob data
Query query = new Query("__BlobInfo__");
query.addFilter("filename", FilterOperator.EQUAL, "nameOfSavedFile");
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
PreparedQuery pq = datastore.prepare(query);
List<Entity> entList = pq.asList(FetchOptions.Builder.withLimit(1));
String blobKeyString = entList.get(0).getKey().getName();
BlobstoreService blobStoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKeyLoaded = new BlobKey(blobKeyString);
blobStoreService.serve(blobKeyLoaded,response);
上記のコードを一度実行すると、うまくいくようです。しかし、既存のファイルを同じ名前の新しいファイルで上書きする目的で同じコードを再度実行すると、古いファイルが提供されるだけです。
古いファイルを新しいファイルで上書きする方法を誰かが説明できますか?
ありがとう!