I am trying to test some code that uses the Blobstore API, but I really don't understand how I should get some files in blobstore. The following does not work:
private BlobKey createBlob(String path) throws Exception { FileService fileService = FileServiceFactory.getFileService(); AppEngineFile file = fileService.createNewBlobFile("foobar"); FileWriteChannel writeChannel = fileService.openWriteChannel(file, true); OutputStream output = Channels.newOutputStream(writeChannel); // copy files, guava-style InputStream input = new FileInputStream(path); assertNotNull(input); ByteStreams.copy(input, output); input.close(); // just in case... output.flush(); output.close(); writeChannel.close(); // U NO WORK!!! BlobKey blobKey = fileService.getBlobKey(file); assertNotNull(blobKey); return blobKey; }
My configuration:
new LocalServiceTestHelper( new LocalBlobstoreServiceTestConfig() //.setNoStorage(true) .setBackingStoreLocation("war/WEB-INF/appengine-generated"), new LocalFileServiceTestConfig() ).setUp();
Any ideas?
source share