2010-08-20 45 views

回答

1

通過遠程API Blob存儲訪問加入三天前:

  • 遠程API現在支持Blob存儲API。 (Changelog

remote_api的工作在數據存儲的最低水平 ,所以一旦你設置 了存根,您不必擔心 的事實,您在遠程數據存儲上操作 :如果您正在直接訪問數據存儲 ,有幾個 注意事項,它的工作原理與 完全相同。 (App Engine Help

+0

但是沒有辦法從代碼上傳對象到blobstore。 – 2010-08-20 14:15:11

+0

我的意思是我只能從blobstore中讀取blob,並且不能將它們放在那裏。 – 2010-08-20 14:16:09

+0

我無法嘗試,我無法訪問Blobstore。 – leoluk 2010-08-20 15:04:07

0

有新的文件API更好的解決方案:http://code.google.com/appengine/docs/python/blobstore/overview.html

這很適合我。這裏是一些示例代碼:

from __future__ import with_statement 
from google.appengine.api import files 
from google.appengine.ext import blobstore 

def get_blob_key(self, data, _type): 
    # Create the file 
    file_name = files.blobstore.create(mime_type = _type) 

    # Open the file and write to it 
    with files.open(file_name, 'a') as f: 
     f.write(data) 

    # Finalize the file. Do this before attempting to read it. 
    files.finalize(file_name) 

    # Get the file's blob key 
    blob_key = files.blobstore.get_blob_key(file_name) 
    return blob_key 
相關問題