Skip to content

Commit ce68269

Browse files
author
Martin Kluska
committed
fixed the incorrect chunk directory - absolute path
Closes #2
1 parent e0da0c0 commit ce68269

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/Save/ChunkSave.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ public function __construct(UploadedFile $file, AbstractHandler $handler, $chunk
5454
$this->chunkFileName = $handler->getChunkFileName();
5555

5656
// buid the full disk path
57-
$this->chunkFullFilePath = $this->chunkStorage()->getDiskPathPrefix().$this->getChunkFilePath();
57+
$this->chunkFullFilePath = $this->getChunkFilePath(true);
5858

5959
$this->handleChunkMerge();
6060
}
6161

6262

6363
/**
6464
* Checks if the file upload is finished (last chunk)
65-
*
65+
*
6666
* @return bool
6767
*/
6868
public function isFinished()
@@ -73,11 +73,13 @@ public function isFinished()
7373
/**
7474
* Returns the chunk file path in the current disk instance
7575
*
76+
* @param bool $absolutePath
77+
*
7678
* @return string
7779
*/
78-
public function getChunkFilePath()
80+
public function getChunkFilePath($absolutePath = false)
7981
{
80-
return $this->getChunkDirectory().$this->chunkFileName;
82+
return $this->getChunkDirectory($absolutePath).$this->chunkFileName;
8183
}
8284

8385
/**
@@ -92,11 +94,21 @@ public function getChunkFullFilePath()
9294
/**
9395
* Returns the folder for the cunks in the storage path on current disk instance
9496
*
97+
* @param boolean $absolutePath
98+
*
9599
* @return string
96100
*/
97-
public function getChunkDirectory()
101+
public function getChunkDirectory($absolutePath = false)
98102
{
99-
return $this->chunkStorage()->directory();
103+
$paths = [];
104+
105+
if ($absolutePath) {
106+
$paths[] = $this->chunkStorage()->getDiskPathPrefix();
107+
}
108+
109+
$paths[] = $this->chunkStorage()->directory();
110+
111+
return implode("", $paths);
100112
}
101113

102114
/**
@@ -155,7 +167,7 @@ protected function buildFullFileFromChunks()
155167
$this->file->getClientMimeType(),
156168
filesize($finalPath), $this->file->getError(),
157169
true // we must pass the true as test to force the upload file
158-
// to use a standart copy method, not move uploaded file
170+
// to use a standart copy method, not move uploaded file
159171
);
160172
}
161173

@@ -215,11 +227,11 @@ public function chunkDisk()
215227
*/
216228
protected function createChunksFolderIfNeeded()
217229
{
218-
$path = $this->getChunkDirectory();
230+
$path = $this->getChunkDirectory(true);
219231

220232
// creates the chunks dir
221233
if (!file_exists($path)) {
222234
mkdir($path, 0777, true);
223235
}
224236
}
225-
}
237+
}

0 commit comments

Comments
 (0)