Skip to content

Commit 5624d5a

Browse files
authored
Merge pull request #22 from agungsijawir/master
Patch for Issues #21
2 parents 9f9663c + 899daa8 commit 5624d5a

File tree

10 files changed

+18
-17
lines changed

10 files changed

+18
-17
lines changed

src/Network/SimpleResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function header($statusCode)
1616
} else if (404==$statusCode) {
1717
return header("HTTP/1.0 404 Not Found");
1818
}
19-
return header("HTTP/1.0 404 Not Found");
19+
return header("HTTP/1.0 204 No Content");
2020
}
2121

2222
}

src/Resumable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function handleTestChunk()
162162
$chunkNumber = $this->resumableParam('chunkNumber');
163163

164164
if (!$this->isChunkUploaded($identifier, $filename, $chunkNumber)) {
165-
return $this->response->header(404);
165+
return $this->response->header(204);
166166
} else {
167167
return $this->response->header(200);
168168
}
@@ -265,7 +265,7 @@ public function tmpChunkDir($identifier)
265265

266266
public function tmpChunkFilename($filename, $chunkNumber)
267267
{
268-
return $filename . '.part' . $chunkNumber;
268+
return $filename . '.' . str_pad($chunkNumber, 4, 0, STR_PAD_LEFT);
269269
}
270270

271271
public function createFileFromChunks($chunkFiles, $destFile)
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/src/Network/SimpleRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testFile()
7676
$file = array(
7777
'name'=> 'mock.png',
7878
'type'=> 'application/octet-stream',
79-
'tmp_name'=> 'test/files/mock.png.part3',
79+
'tmp_name'=> 'test/files/mock.png.0003',
8080
'error'=> 0,
8181
'size'=> 1048576,
8282
);

test/src/Network/SimpleResponseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ public function headerProvider()
2626
{
2727
return array(
2828
array(404,404),
29+
array(204,204),
2930
array(200,200),
30-
array(500,404),
31+
array(500,204),
3132
);
3233
}
3334

test/src/ResumableTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testProcessHandleChunk()
5050
$this->request->method('file')
5151
->will($this->returnValue(array(
5252
'name'=> 'mock.png',
53-
'tmp_name'=> 'test/files/mock.png.part3',
53+
'tmp_name'=> 'test/files/mock.png.003',
5454
'error'=> 0,
5555
'size'=> 27000,
5656
)));
@@ -142,7 +142,7 @@ public function testHandleChunk() {
142142
$this->request->method('file')
143143
->willReturn(array(
144144
'name'=> 'mock.png',
145-
'tmp_name'=> 'test/files/mock.png.part3',
145+
'tmp_name'=> 'test/files/mock.png.003',
146146
'error'=> 0,
147147
'size'=> 27000,
148148
));
@@ -154,7 +154,7 @@ public function testHandleChunk() {
154154
$this->resumbable->handleChunk();
155155

156156
$this->assertFileExists('test/uploads/mock.png');
157-
unlink('test/tmp/identifier/mock.png.part3');
157+
unlink('test/tmp/identifier/mock.png.003');
158158
unlink('test/uploads/mock.png');
159159
}
160160

@@ -226,22 +226,22 @@ public function testTmpChunkFile()
226226
{
227227
$this->resumbable = new Resumable($this->request,$this->response);
228228
$filename = 'mock-file.png';
229-
$chunkNumber = 1;
230-
$expected = $filename.'.part'.$chunkNumber;
229+
$chunkNumber = str_pad(1, 4, 0, STR_PAD_LEFT);
230+
$expected = $filename.'.'.$chunkNumber;
231231
$this->assertEquals($expected, $this->resumbable->tmpChunkFilename($filename,$chunkNumber));
232232
}
233233

234234
public function testCreateFileFromChunks()
235235
{
236236
$files = array(
237-
'test/files/mock.png.part1',
238-
'test/files/mock.png.part2',
239-
'test/files/mock.png.part3',
237+
'test/files/mock.png.0001',
238+
'test/files/mock.png.0002',
239+
'test/files/mock.png.0003',
240240
);
241241
$totalFileSize = array_sum(array(
242-
filesize('test/files/mock.png.part1'),
243-
filesize('test/files/mock.png.part2'),
244-
filesize('test/files/mock.png.part3')
242+
filesize('test/files/mock.png.0001'),
243+
filesize('test/files/mock.png.0002'),
244+
filesize('test/files/mock.png.0003')
245245
));
246246
$destFile = 'test/files/5.png';
247247

@@ -256,7 +256,7 @@ public function testMoveUploadedFile()
256256
{
257257
$destFile = 'test/files/4.png';
258258
$this->resumbable = new Resumable($this->request,$this->response);
259-
$this->resumbable->moveUploadedFile('test/files/mock.png.part1', $destFile);
259+
$this->resumbable->moveUploadedFile('test/files/mock.png.0001', $destFile);
260260
$this->assertFileExists($destFile);
261261
unlink($destFile);
262262
}

0 commit comments

Comments
 (0)