剑韬 付 wrote:
>     if response['Content-Type'].split(';')[0] not in safe_mime_types:
> AttributeError: 'tuple' object has no attribute 'split'

> here is the code snippets:
>     resp = HttpResponse(S3FileIter(block_hash_list, data_start, 
> content_length),\
>                         mimetype = 
> mimetypes.guess_type(os.path.basename(request.REQUEST['srv_path'])))

> 1.what's the reason of problem

mimetypes.guess_type() returns a tuple as explained at
http://docs.python.org/library/mimetypes.html and HttpResponse expects a
string, as explained at
http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponse.__init__

> 3.How to solve the problem

Pass in the first element of the tuple, not the tuple. Though you should
probably check that guess_type() is actually returning a valid content
type first, rather than just assuming it will.

ATB,
Matthew
http://www.dracos.co.uk/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to