本文整理匯總了Python中storages.compat.BytesIO.mode方法的典型用法代碼示例。如果您正苦於以下問題:Python BytesIO.mode方法的具體用法?Python BytesIO.mode怎麽用?Python BytesIO.mode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類storages.compat.BytesIO
的用法示例。
在下文中一共展示了BytesIO.mode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _open
# 需要導入模塊: from storages.compat import BytesIO [as 別名]
# 或者: from storages.compat.BytesIO import mode [as 別名]
def _open(self, name, mode='rb'):
"""Open a file from database.
@param name filename or relative path to file based on base_url. path should contain only "/", but not "\". Apache sends pathes with "/".
If there is no such file in the db, returs None
"""
assert mode == 'rb', "You've tried to open binary file without specifying binary mode! You specified: %s"%mode
row = self.cursor.execute("SELECT %s from %s where %s = '%s'"%(self.blob_column,self.db_table,self.fname_column,name) ).fetchone()
if row is None:
return None
inMemFile = BytesIO(row[0])
inMemFile.name = name
inMemFile.mode = mode
retFile = File(inMemFile)
return retFile