1
votes

I tried to use the experimental Writing Files to Blobstore and even with the demo code, I keep getting FinalizationException upon trying to read the file.

The code I use is below:

FileService fileService = FileServiceFactory.getFileService();

AppEngineFile file = null;
file = fileService.createNewBlobFile("text/plain");

FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);

PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"));
out.println("The woods are lovely dark and deep.");
out.println("But I have promises to keep.");

out.close();
String path = file.getFullPath();

file = new AppEngineFile(path);

writeChannel = fileService.openWriteChannel(file, true);

writeChannel.write(ByteBuffer.wrap("And miles to go before I sleep.".getBytes()));

writeChannel.closeFinally();

The read code where I get the FinalizationException within another request is as below:

    FileService fileService = FileServiceFactory.getFileService();

    String path = //get the path code       
    AppEngineFile file = new AppEngineFile(path);

    FileReadChannel readChannel;
    try {
        readChannel = fileService.openReadChannel(file, false);
    } catch (FileNotFoundException e) { }

I get the Finalization Exception at the openReadChannel line

Any help would be appreciated.

1
have you resolved something? I am stuck on a similar problem - Michele Orsi
Seconded, did you resolved this issue? - While-E

1 Answers

0
votes

This example works fine on development server.