esbenp / esbenp/fineuploader-server

$file->getType() being called after temp dir has been deleted

Open
#10 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
7
Forks
11
PR merge metrics
No merged PRs in 30d

Description

Laravel 5.4

I am getting the following error when I try upload with fineUploader:

`ErrorException
exif_imagetype(/home/vagrant/wed/storage/uploader/temp/a772c5d4-06a7-4b8f-aecf-7dd78c8c196e/59aee10d2c4f4.jpg): failed to open stream: No such file or directory`

It seems that in prepareUploadSuccessfulResponse $file->getType() is called which is looking for the file in the temp dir, after the directory has been deleted in Uploader.php line 96

As a quick fix I have commented out the file_type line but would love to find a proper solution

private function prepareUploadSuccessfulResponse(array $response, RootFile $file)
{
return array_merge($response, [
'type' => 'upload',
'success' => true,
//'file_type' => $file->getType(),
'original_name' => $file->getOriginalName(),
'upload_path' => $this->clearFileExtension($file->getName())
]);
}

Contributor guide

Open the contributing guide

Research direction

Start in Uploader.php around line 96 and trace the cleanup of the temporary directory before prepareUploadSuccessfulResponse in the upload response flow. Reproduce a fineUploader upload and inspect the $file->getType() call; done means the successful response no longer attempts to read a deleted temporary file while retaining the expected upload metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.