Skip to content

Chunk are appended in the wrong order when the upload creates 10 chunks or more #38

Closed
@kerwan

Description

@kerwan

If you make an upload that leads to more than 10 chunks, they are appended in the wrong order.
I think this has to do with the sort function which does not take the part numbers into account correctly.
So file xxxxxxxx-10.part is appended before xxxxxxxx-2.part because of the sorting.

I have already applied the fix proposed in another thread by setting browser = true and session = false
for the filenames. So I assured my part filenames are consistent throught the whole upload.

I am using dropzone.js to handle the upload client side, and I checked that the chunk indexes, order and total are all correct.

Sorting the files with natural case seems to fix the problem.
In function buildFullFileFromChunks() from ParallelSave.php

$chunkFiles = $this->savedChunksFiles()->sort();

I replace with this

// Sorting file collection with natural case so xxxx-10.part does not get before xxxx-2.part
$chunkFiles = $this->savedChunksFiles();
$items = $chunkFiles->all();
natcasesort($items);
$chunkFiles = collect($items);

And it solves the problem.

If this a mistake from me that can be resolved without updating the plugin, I'll be happy to be directed to the solution.

Apart from this, it is an excellent plugin :-).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions