Skip to content

Corrupted path detected #143 #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/chunk-upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'use' => [
'session' => true, // should the chunk name use the session id? The uploader must send cookie!,
'browser' => false, // instead of session we can use the ip and browser?
'hashName' => false // use a hash name instead of the original file name
],
],
],
Expand Down
11 changes: 8 additions & 3 deletions src/Commands/ClearChunksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\Str;
use Pion\Laravel\ChunkUpload\ChunkFile;
use Pion\Laravel\ChunkUpload\Storage\ChunkStorage;
use RuntimeException;
use Symfony\Component\Console\Output\OutputInterface;

class ClearChunksCommand extends Command
Expand Down Expand Up @@ -51,9 +52,13 @@ public function handle(ChunkStorage $storage)
$this->comment('> '.$file, $verbouse);

// delete the file
if ($file->delete()) {
++$deleted;
} else {
try{
if ($file->delete()) {
++$deleted;
} else {
$this->error('> chunk not deleted: '.$file);
}
}catch(RuntimeException $err){
$this->error('> chunk not deleted: '.$file);
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/Config/AbstractConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ abstract public function chunkUseSessionForName();
* @return bool
*/
abstract public function chunkUseBrowserInfoForName();

/**
* Should the chunk name add a hash name instead of original file name?
*
* @return bool
*/
abstract public function chunkUseHashNameForName();
}
10 changes: 10 additions & 0 deletions src/Config/FileConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public function chunkUseBrowserInfoForName()
return $this->get('chunk.name.use.browser', false);
}

/**
* Should the chunk name add a hash name instead of original file name?
*
* @return bool
*/
public function chunkUseHashNameForName()
{
return $this->get('chunk.name.use.hashName', false);
}

/**
* Returns a chunks config value.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Handler/AbstractHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function createChunkFileName($additionalName = null, $currentChunkIndex =
{
// prepare basic name structure
$array = [
$this->file->getClientOriginalName(),
$this->config->chunkUseHashNameForName() ? md5($this->file->getClientOriginalName()) : $this->file->getClientOriginalName(),
];

// ensure that the chunk name is for unique for the client session
Expand Down