Comments (6)
What kind of binary files did you try to upload?
And was the file size matching?
More information would be helpful.
from resumable.php.
A few issues I see here:
- When combining chunked files, the order is messed up due to not being naturally sorted. Running natsort against the $chunkFiles array inside the createFileFromChunks should fix this.
- Sometimes, the folder holding your temp chunked files gets deleted first before the process of combining files gets completed. You then end up with errors such as being unable to call file_get_contents('/path/to/chunked/file') due to the file getting deleted.
- Haven't tested this fully yet but it looks like fopen in append mode doesn't work well with certain types of files like large binary files. Cake's File class' append method uses this and well, it just breaks the resulting file. Modifying the createFileFromChunks() method to do something similar to how the other PHP implementation sample (https://github.com/23/resumable.js/blob/master/samples/Backend%20on%20PHP.md) works fixes this issue. Quick example below
public function createFileFromChunks($chunkFiles, $destFile)
{
natsort($chunkFiles);
if (($fp = fopen($destFile, 'w')) !== false) {
foreach ($chunkFiles as $chunkFile) {
if (fwrite($fp, file_get_contents($chunkFile))) {
unlink($chunkFile);
}
}
fclose($fp);
}
return true;
}
I would imagine combining these 3 should fix the issues encountered by @NewPlayer2
EDIT:
I may be wrong with _#_2. I think the reason for that error is because on certain uploads, the isFileUploadComplete method returns true multiple times at the end of some chunks. Might be something wrong with your math but I think you can just use the resumableTotalChunks value to determine the exact number of chunks resumable has created. The error in _#_3 might also be related to this.
from resumable.php.
I will try to replicate the issues as soon as I have some free time.
Looks like I will have to test couple of file formats:
- video
- binary
from resumable.php.
added condition to delete tmp folder only when file is combined from chunks.
from resumable.php.
Issues should be fixed with 0.1.2.
from resumable.php.
The problem still persists with partly uploaded ZIP files. If you try to reupload after page refresh, then uploaded file is corrupted and file size doesn't match original file.
Solved this by using @georaldc solution:
public function createFileFromChunks($chunkFiles, $destFile)
{
$this->log('Beginning of create files from chunks');
natsort($chunkFiles);
if (($fp = fopen($destFile, 'w')) !== false) {
foreach ($chunkFiles as $chunkFile) {
fwrite($fp, file_get_contents($chunkFile));
$this->log('Append ', ['chunk file' => $chunkFile]);
}
fclose($fp);
}
$this->log('End of create files from chunks');
return true;
}
Also dropped out unlink(...), because we have $tmpFolder->delete(); which deletes whole folder and everything inside it.
from resumable.php.
Related Issues (20)
- CakePHP Folder.php class issue. HOT 1
- Cannot make it work, error in script HOT 2
- This doesn't work in the latest version ? HOT 3
- Request type detection HOT 1
- SimpleRequest is empty HOT 1
- frontend HOT 7
- mkdir file exists HOT 13
- Update composer package HOT 1
- Server returns 200 when file paths are wrong HOT 1
- Code is not working out of the box HOT 4
- BUG: File large than chunksize, possible corrupt after merging.
- headers and HTTP 1.1 HOT 2
- Resumable is not defined HOT 6
- Monolog HOT 1
- Broke framework compatibility HOT 1
- if the last chunk reach at last it will fail HOT 1
- Composer Install Error HOT 2
- how to override new FileName if FileExist and return Filename as response??? HOT 1
- Security vulnerability - arbitrary file upload anywhere in the file system HOT 7
- Make Contribution HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resumable.php.