fixed attachments upload on Windows

This commit is contained in:
slav0nic 2010-02-18 11:04:35 +02:00
parent 0b67e1e09d
commit ed7f7b1620
2 changed files with 2 additions and 2 deletions

View file

@ -106,7 +106,7 @@ class AddPostForm(forms.ModelForm):
dir = os.path.join(settings.MEDIA_ROOT, forum_settings.ATTACHMENT_UPLOAD_TO)
fname = '%d.0' % post.id
path = os.path.join(dir, fname)
file(path, 'w').write(memfile.read())
file(path, 'wb').write(memfile.read())
obj.path = fname
obj.save()

View file

@ -783,7 +783,7 @@ def add_subscription(request, topic_id):
@login_required
def show_attachment(request, hash):
attachment = get_object_or_404(Attachment, hash=hash)
file_data = file(attachment.get_absolute_path()).read()
file_data = file(attachment.get_absolute_path(), 'rb').read()
response = HttpResponse(file_data, mimetype=attachment.content_type)
response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(attachment.name)
return response