首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用blobstore存储MIME类型

使用blobstore存储MIME类型
EN

Stack Overflow用户
提问于 2011-05-03 06:49:46
回答 1查看 799关注 0票数 1

如何也将传入blob的MIME类型存储到blobstore?我现在既不能获取使用处理程序blobstore_handlers.BlobstoreUploadHandler存储的名称,也不能获取存储的MIME类型。下面是我的不使用blobstore_handlers.BlobstoreUploadHandler的代码

代码语言:javascript
复制
    def create_image(number, self, file, ad):
        logging.debug('creating image')            
        try:
          file_name = files.blobstore.create()
          with files.open(file_name, 'a') as f:
              f.write(file)
          files.finalize(file_name)
          blob_key = files.blobstore.get_blob_key(file_name)
          logging.debug('creating image')
          img = Image(reference=ad) 
          logging.debug('creating image')
          img.primary_image = blob_key
          logging.debug('creating image')
          img.put()
          ad.put()
        except Exception:                
           self.response.write(Exception)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-03 07:21:49

name和mime类型都可以作为参数传递到create:

代码语言:javascript
复制
def create(mime_type='application/octet-stream',
           _blobinfo_uploaded_filename=None):
  """Create a writable blobstore file.

  Args:
    mime_type: Resulting blob content MIME type as string.
    _blobinfo_uploaded_filename: Resulting blob's BlobInfo file name as string.

  Returns:
    A file name for blobstore file. This file can be opened for write
    by File API open function. To read the file or obtain its blob key, finalize
    it and call get_blob_key function.
  """
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5863305

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档