Clearing AppBanner BlobStore

There are a lot of orphan blobs in my AppEngine server that are not used in BlobStore. I would like to write code to iterate over all blobs and check if they are not being used and then delete. I can't seem to find a way to iterate over BlobStore. Is it possible?


source to share

2 answers

You can list via a datastore request (although such a request is ultimately agreed upon).



Here is a code-behind solution for iterating over blobs in golang:

c.Infof("Iterating over blobs")
q := datastore.NewQuery("__BlobInfo__")

// Iterate over the results.
total := 0
t := q.Run(c)
for {
        var bi blobstore.BlobInfo
        _, err := t.Next(&bi)
        if err == datastore.Done {
        if err != nil && isErrFieldMismatch(err) == false {
                c.Errorf("Error fetching next Blob: %v", err)
        // Do something with the Blob bi
        c.Infof("Got blob [%v] of size [%v]", bi.ContentType, bi.Size)
        if total > 100 { break }
c.Infof("Iterating Done")


You will also need to use this function to ignore field mismatch errors:

func isErrFieldMismatch(err error) bool {
    _, ok := err.(*datastore.ErrFieldMismatch)
    return ok





All Articles