删除 appengine blobstore 中的孤立 blob
我从数据存储中删除了大量我不删除的对象 需要(大约 7000 个)。 每个对象都有一个与其关联的 blob,由 字符串(blob 键)。
正如您现在可能已经猜到的那样,我忘记删除这些斑点。 现在我对它们没有任何参考,但我想删除它们。 我似乎找不到办法做到这一点。 任何帮助将不胜感激。
更新 找到了解决方案。
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);
I deleted a large number of objects from the datastore that I din't
require (around 7000 of them).
Each of those objects had a blob associated with it, referenced by a
String (blob key).
As you might have guessed by now, I forgot to delete those blobs.
Now I don't have any reference to them, but I want to delete them.
I can't seem to find a way to do that.
Any help will be appreciated.
UPDATE
Found the 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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新 找到了解决方案,BlobInfoFactory().queryBlobInfos() 就是我正在寻找的。
UPDATE Found the solution, BlobInfoFactory().queryBlobInfos() is what I was looking for.