Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot delete GAE file

I'm trying to remove a file after a broken upload using

final FileService fileService = FileServiceFactory.getFileService();
fileService.delete(file);

But I get:

java.lang.UnsupportedOperationException: File \/blobstore\/writable:AD8BvukH[...]qau-Bb7AD does not have a finalized name

When I try to finalize the file with

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

then openWriteChannel() fails with

com.google.appengine.api.files.FinalizationException
[...]
Caused by: com.google.apphosting.api.ApiProxy$ApplicationException: ApplicationError: 101: 

What does ApplicationError 101 mean? How can I properly delete the file?

like image 273
Michael Avatar asked Jan 09 '14 13:01

Michael


1 Answers

It looks like others have reported this problem and, although it was addressed, there could still be a problem with broken files.

Sep 11, 2013 at 1:14 am

We have now fixed this issue from reoccurring in future. However, there are some blobs created in the past that still give errors. We are working on a fix for these blobs.

John Lowry On behalf of the App Engine team

http://grokbase.com/t/gg/google-appengine/138xrawqw0/broken-blobstore-files-what-to-do

UnsupportedOperationException

For the first error, the documentation states:

java.lang.UnsupportedOperationException - if a file's type is not supported by delete or file does not have a finalized name.

It could be that the file is already finalized, and you can't delete it for some other reason.

ApplicationError: 101

I think the second error refers to a not found exception.

FinalizationError: ApplicationError: 101 Blobkey not found.

This may clarify the issue for you.

You only use finalize if you create a file and write to it. But you cannot write to a file, after it has been finalized. To update a file in the blobstore, you always have to create a new one. And when you read a file, you do not have to finalize it. To read a file you have to use a blobreader. See: https://developers.google.com/appengine/docs/python/blobstore/blobreaderclass

via https://stackoverflow.com/a/12855653/1085891

Fixing the Broken Upload

You could resume the upload.

If the transfer is interrupted, you can resume the transfer from where it left off using the --db_filename=... argument.

via How to finish a broken data upload to the production Google App Engine server?

Additional Solutions / Information:

  • Cannot delete entity with broken id from datastore
  • Handle Form Failure when uploading to Appengine Blobstore
  • Issue 4744: Java dev server fails at deleting blobs.
like image 145
JSuar Avatar answered Oct 13 '22 23:10

JSuar