mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix bug that would report wrong file size to browser.
This commit is contained in:
parent
cbe3fb73a8
commit
9244994233
@ -18,6 +18,7 @@ use FireflyIII\Http\Requests\AttachmentFormRequest;
|
|||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
use Input;
|
use Input;
|
||||||
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Response;
|
use Response;
|
||||||
use Session;
|
use Session;
|
||||||
@ -93,9 +94,11 @@ class AttachmentController extends Controller
|
|||||||
if ($disk->exists($file)) {
|
if ($disk->exists($file)) {
|
||||||
|
|
||||||
$quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
|
$quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
|
||||||
|
$content = Crypt::decrypt($disk->get($file));
|
||||||
|
|
||||||
|
Log::debug('Send file to user', ['file' => $quoted, 'size' => strlen($content)]);
|
||||||
|
|
||||||
return response(Crypt::decrypt($disk->get($file)), 200)
|
return response($content, 200)
|
||||||
->header('Content-Description', 'File Transfer')
|
->header('Content-Description', 'File Transfer')
|
||||||
->header('Content-Type', 'application/octet-stream')
|
->header('Content-Type', 'application/octet-stream')
|
||||||
->header('Content-Disposition', 'attachment; filename=' . $quoted)
|
->header('Content-Disposition', 'attachment; filename=' . $quoted)
|
||||||
@ -104,7 +107,7 @@ class AttachmentController extends Controller
|
|||||||
->header('Expires', '0')
|
->header('Expires', '0')
|
||||||
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
||||||
->header('Pragma', 'public')
|
->header('Pragma', 'public')
|
||||||
->header('Content-Length', $disk->size($file));
|
->header('Content-Length', strlen($content));
|
||||||
|
|
||||||
}
|
}
|
||||||
throw new FireflyException('Could not find the indicated attachment. The file is no longer there.');
|
throw new FireflyException('Could not find the indicated attachment. The file is no longer there.');
|
||||||
|
Loading…
Reference in New Issue
Block a user