本文整理匯總了Python中rest_framework.parsers.FileUploadParser.get_filename方法的典型用法代碼示例。如果您正苦於以下問題:Python FileUploadParser.get_filename方法的具體用法?Python FileUploadParser.get_filename怎麽用?Python FileUploadParser.get_filename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rest_framework.parsers.FileUploadParser
的用法示例。
在下文中一共展示了FileUploadParser.get_filename方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_encoded_filename
# 需要導入模塊: from rest_framework.parsers import FileUploadParser [as 別名]
# 或者: from rest_framework.parsers.FileUploadParser import get_filename [as 別名]
def test_get_encoded_filename(self):
parser = FileUploadParser()
self.__replace_content_disposition('inline; filename*=utf-8\'\'ÀĥƦ.txt')
filename = parser.get_filename(self.stream, None, self.parser_context)
assert filename == 'ÀĥƦ.txt'
self.__replace_content_disposition('inline; filename=fallback.txt; filename*=utf-8\'\'ÀĥƦ.txt')
filename = parser.get_filename(self.stream, None, self.parser_context)
assert filename == 'ÀĥƦ.txt'
self.__replace_content_disposition('inline; filename=fallback.txt; filename*=utf-8\'en-us\'ÀĥƦ.txt')
filename = parser.get_filename(self.stream, None, self.parser_context)
assert filename == 'ÀĥƦ.txt'
示例2: test_get_encoded_filename
# 需要導入模塊: from rest_framework.parsers import FileUploadParser [as 別名]
# 或者: from rest_framework.parsers.FileUploadParser import get_filename [as 別名]
def test_get_encoded_filename(self):
parser = FileUploadParser()
self.__replace_content_disposition("inline; filename*=utf-8''ÀĥƦ.txt")
filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, "ÀĥƦ.txt")
self.__replace_content_disposition("inline; filename=fallback.txt; filename*=utf-8''ÀĥƦ.txt")
filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, "ÀĥƦ.txt")
self.__replace_content_disposition("inline; filename=fallback.txt; filename*=utf-8'en-us'ÀĥƦ.txt")
filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, "ÀĥƦ.txt")
self.__replace_content_disposition("inline; filename=fallback.txt; filename*=utf-8--ÀĥƦ.txt")
filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, "fallback.txt")
示例3: test_get_encoded_filename
# 需要導入模塊: from rest_framework.parsers import FileUploadParser [as 別名]
# 或者: from rest_framework.parsers.FileUploadParser import get_filename [as 別名]
def test_get_encoded_filename(self):
parser = FileUploadParser()
self.__replace_content_disposition('inline; filename*=utf-8\'\'ÀĥƦ.txt')
filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, 'ÀĥƦ.txt')
self.__replace_content_disposition('inline; filename=fallback.txt; filename*=utf-8\'\'ÀĥƦ.txt')
filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, 'ÀĥƦ.txt')
self.__replace_content_disposition('inline; filename=fallback.txt; filename*=utf-8\'en-us\'ÀĥƦ.txt')
filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, 'ÀĥƦ.txt')
self.__replace_content_disposition('inline; filename=fallback.txt; filename*=utf-8--ÀĥƦ.txt')
filename = parser.get_filename(self.stream, None, self.parser_context)
# Malformed. Either None or 'fallback.txt' will be acceptable.
# See also https://code.djangoproject.com/ticket/24209
self.assertIn(filename, ('fallback.txt', None))
示例4: test_get_filename
# 需要導入模塊: from rest_framework.parsers import FileUploadParser [as 別名]
# 或者: from rest_framework.parsers.FileUploadParser import get_filename [as 別名]
def test_get_filename(self):
parser = FileUploadParser()
filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, 'file.txt'.encode('utf-8'))
示例5: test_get_filename
# 需要導入模塊: from rest_framework.parsers import FileUploadParser [as 別名]
# 或者: from rest_framework.parsers.FileUploadParser import get_filename [as 別名]
def test_get_filename(self):
parser = FileUploadParser()
filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, "file.txt")
示例6: test_get_filename
# 需要導入模塊: from rest_framework.parsers import FileUploadParser [as 別名]
# 或者: from rest_framework.parsers.FileUploadParser import get_filename [as 別名]
def test_get_filename(self):
parser = FileUploadParser()
filename = parser.get_filename(self.stream, None, self.parser_context)
assert filename == 'file.txt'