如何在迁移到HRD后恢复Blob [英] How can i recover Blobs after migration to HRD
本文介绍了如何在迁移到HRD后恢复Blob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从servlet未捕获到的异常
java.lang.SecurityException:此应用程序无权访问该Blob。
at com.google.appengine.api.blobstore.BlobstoreServiceImpl.fetchData(BlobstoreServiceImpl.java:200)
at com.droidastic.telljokes.server.servlet.ServeBlobsServlet.checkBlobKeyExists(ServeBlobsServlet.java:100)
at com.droidastic.telljokes.server.servlet.ServeBlobsServlet.doGet(ServeBlobsServlet.java:64)
我将这些键作为字符串存储在数据存储实体中,然后我将它们创建为这样:
BlobKey key =新的BlobKey(this.params.blobKey);
如何恢复斑点?
解决方案
我找到了一个解决方案:
public String getMigratedBlobKey(String oldKey){
String migrationEntityKey =__BlobMigration__;
Key createKey = KeyFactory.createKey(migrationEntityKey,oldKey);
实体migrationEntity = datastore.get(createKey);
BlobKey newKey =(BlobKey)migrationEntity.getProperty(new_blob_key);
返回newKey.getKeyString();
}
__BlobMigration__和new_blob_key是GAE常数。
I just migrated to HRD and now its telling me i cant access my own blobs...
Uncaught exception from servlet
java.lang.SecurityException: This application does not have access to that blob.
at com.google.appengine.api.blobstore.BlobstoreServiceImpl.fetchData(BlobstoreServiceImpl.java:200)
at com.droidastic.telljokes.server.servlet.ServeBlobsServlet.checkBlobKeyExists(ServeBlobsServlet.java:100)
at com.droidastic.telljokes.server.servlet.ServeBlobsServlet.doGet(ServeBlobsServlet.java:64)
I stored the keys as a string inside the datastore entities and then i create them like this:
BlobKey key = new BlobKey(this.params.blobKey);
How can i recover the blobs?
解决方案
I found a solution:
public String getMigratedBlobKey(String oldKey) {
String migrationEntityKey = "__BlobMigration__";
Key createKey = KeyFactory.createKey(migrationEntityKey, oldKey);
Entity migrationEntity = datastore.get(createKey);
BlobKey newKey = (BlobKey) migrationEntity.getProperty("new_blob_key");
return newKey.getKeyString();
}
"__BlobMigration__" and "new_blob_key" are GAE constants.
这篇关于如何在迁移到HRD后恢复Blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文