Giter Site home page Giter Site logo

Comments (6)

dilab avatar dilab commented on July 22, 2024

What kind of binary files did you try to upload?

And was the file size matching?

More information would be helpful.

from resumable.php.

georaldc avatar georaldc commented on July 22, 2024

A few issues I see here:

  1. 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.
  2. 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.
  3. 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.

dilab avatar dilab commented on July 22, 2024

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:

  1. video
  2. binary

from resumable.php.

dilab avatar dilab commented on July 22, 2024

added condition to delete tmp folder only when file is combined from chunks.

from resumable.php.

dilab avatar dilab commented on July 22, 2024

Issues should be fixed with 0.1.2.

from resumable.php.

daitam avatar daitam commented on July 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.