Skip to content

Commit

Permalink
Fix bug when running on windows that was causing file upload validati…
Browse files Browse the repository at this point in the history
…on to fail
  • Loading branch information
talvbansal committed Jun 11, 2017
1 parent 1d67a56 commit e433da9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions public/js/media-manager.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/Http/Requests/UploadFileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public function authorize()
public function rules()
{
return [
'files' => 'required|array',
'files.*' => 'required|file',

This comment has been minimized.

Copy link
@mopo922

mopo922 Jun 17, 2017

This breaks validation for Linux systems. Now I'm getting "Unprocessable entity" in the UI with the following message in the AJAX response:

{"files.length":["The files.length must be a file."],"files.item":["The files.item must be a file."]}

I know very little about Windows, otherwise I'd offer a solution.

This comment has been minimized.

Copy link
@ruchernchong

ruchernchong Jun 18, 2017

This validation did not break on my production server (Ubuntu) for many of the projects. I don't think this is the problem.

This comment has been minimized.

Copy link
@mopo922

mopo922 Jun 18, 2017

Interesting. When I changed this back to the original ('files' => 'required|array',), files started uploading fine again. I'm on Ubuntu 14. For now, I've fixed my media-manager version at 2.5.0 in composer.json so uploads keep working.

This comment has been minimized.

Copy link
@ruchernchong

ruchernchong Jun 18, 2017

Hmmm, that's a really weird issue then. I will try again see what happens.

This comment has been minimized.

Copy link
@mopo922

mopo922 Jun 18, 2017

I'm on Laravel 5.3 - are your projects on 5.4? I'll try upgrading to see if that resolves it.

This comment has been minimized.

Copy link
@ruchernchong

ruchernchong Jun 18, 2017

Yes, mine is on 5.4

This comment has been minimized.

Copy link
@talvbansal

talvbansal Jun 18, 2017

Author Owner

Hi Guys, have you make sure to update the UI components? They may be the source of your problems, if you have an you're sure this is an issue I'll look into this more.

'folder' => 'required',
];
}

}
2 changes: 1 addition & 1 deletion src/Services/MediaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function folderInfo($folder = '/')
*/
protected function cleanFolder($folder)
{
return '/'.trim(str_replace('..', '', $folder), '/');
return DIRECTORY_SEPARATOR.trim(str_replace('..', '', $folder), DIRECTORY_SEPARATOR);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/MediaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function test_does_not_list_hidden_files()
*/
public function test_can_create_folder()
{
$folderName = DIRECTORY_SEPARATOR.date('Y-m-d H:i:s');
$folderName = DIRECTORY_SEPARATOR.date('Y-m-d');

// create
$response = $this->mediaManager->createDirectory($folderName);
Expand Down Expand Up @@ -208,7 +208,7 @@ public function test_cannot_create_a_folder_that_already_exists()
public function test_can_delete_a_folder()
{
// create a folder
$folderName = DIRECTORY_SEPARATOR.date('Y-m-d H:i:s');
$folderName = DIRECTORY_SEPARATOR.date('Y-m-d');
$response = $this->mediaManager->createDirectory($folderName);

// is created ?
Expand Down

0 comments on commit e433da9

Please sign in to comment.