开发者

Using GAE FileService API

开发者 https://www.devze.com 2023-04-12 23:50 出处:网络
Im using the following code just for learning how to use the FIleService API, but im always getting null on the blobkey, here is the code:

Im using the following code just for learning how to use the FIleService API, but im always getting null on the blobkey, here is the code:

    AppEngineFile file = fileService.createNewBlobFile("text/plain");
    BlobKey key = fileService.getBlobKey(file);
    System.out.println("Blobkey: "+key);

It always prints Blobkey: null

Anyone kno开发者_运维技巧w what im doing wrong. I tried the example http://code.google.com/appengine/docs/java/blobstore/overview.html#Writing_Files_to_the_Blobstore but I just cant get it to work.


My guess, seeing the difference between your code and the one in the example, is that a blob key is associated with the file only if some blob has been created, i.e. if you have written something to the file and finalized it.

BTW, if you read the api doc, it says

Given a BLOBSTORE file that has been finalized, returns the BlobKey for the corresponding blob.

(emphasis mine)

0

精彩评论

暂无评论...
验证码 换一张
取 消