Hi, I'm trying to save a file to the blobstore similar to what is described in docs at this page:
http://code.google.com/appengine/docs/java/blobstore/overview.html#Writing_Files_to_the_Blobstore My code to write the file is: // Create a new Blob file with mime-type "text/html" AppEngineFile file = fileService.createNewBlobFile("text/html"); // Open a channel to write to it boolean lock = true; writeChannel = fileService.openWriteChannel(file, lock); PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8")); out.print(htmlText); // Close without finalizing and save the file path for writing later out.close(); filePath = file.getFullPath(); writeChannel.closeFinally(); I then save the filePath as a field on one of my Datastore entities. However when I try and read it back, the following code falls into the catch for FileNotFound exception: public String fetchHtml(String remoteUrl) { StringBuilder sb = new StringBuilder(); String returnString = null; FileService fileService = FileServiceFactory.getFileService(); FixtureEntity fixture = getRecordByRemoteUrl(remoteUrl); String fileName = fixture.getFileName(); AppEngineFile file = new AppEngineFile(fileName); FileReadChannel readChannel; try { readChannel = fileService.openReadChannel(file, false); BufferedReader reader = new BufferedReader(Channels.newReader( readChannel, "UTF8")); String inputLine; while ((inputLine = reader.readLine()) != null) { sb.append(inputLine); } // line = "The woods are lovely dark and deep." readChannel.close(); returnString = sb.toString(); } catch (FileNotFoundException e) { logger.warning(e.getMessage()); } catch (LockException e) { logger.warning(e.getMessage()); } catch (IOException e) { logger.warning(e.getMessage()); } return returnString; } I'm working on the dev server, with SDK v1.6.1. If I look in the Datastore Viewer, the fileName is set on my entity to /blobstore/ writable:4IoqzMo2yJHJ7336lvNABg. There are __BlobInfo__ entities, but all their "filename" properties are null. If I do this: FileService fileService = FileServiceFactory.getFileService(); BlobKey key = fileService.getBlobKey(file); if (key == null) { Thread.sleep(2000); key = fileService.getBlobKey(file); } Key definitely gets populated. So I'm not sure why readChannel = fileService.openReadChannel(file, false); isn't working. Can anyone see anything obviously wrong with my code? Or have any suggestions as to how to get things working? Many thanks in advance, Andrew. -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.