删除 appengine blobstore 中的孤立 blob

发布于 2024-10-24 00:56:30 字数 851 浏览 3 评论 0原文

我从数据存储中删除了大量我不删除的对象 需要(大约 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

王权女流氓 2024-10-31 00:56:30

更新 找到了解决方案,BlobInfoFactory().queryBlobInfos() 就是我正在寻找的。

    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);

UPDATE Found the 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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文