Removing orphan blobs in appblog blobstore

I deleted a large number of objects from the data store, which I did not delete require (about 7000 of them). Each of these objects had a blob associated with it, referenced by a String (blob key).

As you might have guessed, I forgot to remove these drops. Now I do not have a link to them, but I want to delete them. I can't seem to find a way to do this. Any help would be appreciated.

UPDATE Found a solution.

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); List<BlobInfo> blobsToCheck = new LinkedList<BlobInfo>(); Iterator<BlobInfo> iterator = null; if(afterBlobKey == null){ iterator = new BlobInfoFactory().queryBlobInfos(); }else{ iterator = new BlobInfoFactory().queryBlobInfosAfter(new BlobKey(afterBlobKey)); } while(iterator.hasNext()){ blobsToCheck.add(iterator.next()); } //Check those blobs if they have reference in datastore //Delete using blobstoreService.delete(blobKey); 
+4
source share
1 answer

UPDATE Found a solution, BlobInfoFactory (). queryBlobInfos () is what I was looking for.

  DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); List<BlobInfo> blobsToCheck = new LinkedList<BlobInfo>(); Iterator<BlobInfo> iterator = null; if(afterBlobKey == null){ iterator = new BlobInfoFactory().queryBlobInfos(); }else{ iterator = new BlobInfoFactory().queryBlobInfosAfter(new BlobKey(afterBlobKey)); } while(iterator.hasNext()){ blobsToCheck.add(iterator.next()); } //Check those blobs if they have reference in datastore //Delete using blobstoreService.delete(blobKey); 
+11
source

Source: https://habr.com/ru/post/1344372/


All Articles