Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed bug with incorrect mime type #183

Merged
merged 1 commit into from

5 participants

@stillman

Issue #4344.

@shadowhand
Owner

Why would using $filename in this context cause an issue?

@stillman

Because file name that will be show in the download/open file dialog is in the $download variable and it seems logical to get mime type for it. Original file may not have extension at all (especially when download is generated from the current response [Use TRUE for the filename to send the current response as the file content])

@cs278

If $filename is true it uses $download for the MIME type.

@stillman

Okay, I want to give the user file named "picture.jpg", but the original file stored as md5_file($file) (without extension). What mime type should be in this case?

@shadowhand
Owner

Ah, I see... the sent filename should match the sent mime-type.

Please create an issue and reference the pull request so that this doesn't get lost. Editing the pull request to also edit the ticket gets bonus points.

Thanks!

@shadowhand shadowhand merged commit e6ed617 into kohana:3.2/develop
@ThePixelDeveloper

This commit breaks the send_file functionality.

The second argument is the download name and usually doesn't exist on the file system. For example, I might serving the file:

/var/www/website.com/public/upload/files/0/000/004/0000004639.jpeg

with the download name as:

user-screenshot.jpeg

The failure comes from File::mime; It tries to load the file to find its mime type. Line 45 of kohana/file.php. This needs to be reverted.

Fixed by e139a64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 26, 2011
  1. Fixed bug with incorrect mime type

    Spider authored
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  classes/kohana/response.php
View
2  classes/kohana/response.php
@@ -446,7 +446,7 @@ public function send_file($filename, $download = NULL, array $options = NULL)
if ( ! isset($mime))
{
// Get the mime type
- $mime = File::mime($filename);
+ $mime = File::mime($download);
}
// Open the file for reading
Something went wrong with that request. Please try again.