Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last part of chunk not merged with laravel 8 #120

Open
jazz7381 opened this issue Mar 31, 2021 · 6 comments
Open

Last part of chunk not merged with laravel 8 #120

jazz7381 opened this issue Mar 31, 2021 · 6 comments
Labels

Comments

@jazz7381
Copy link

the file i upload use dropdown js with chunk is corrupted, the last chunk not merged.

i use laravel 8

@pionl
Copy link
Owner

pionl commented Mar 21, 2022

You are free to debug it and fix it? My tests were working. Maybe there will be a bug in special environment while sorting the chunks.

@pionl pionl added the waiting label Mar 21, 2022
@braulioholtz
Copy link

braulioholtz commented Jul 13, 2022

Did you find the solution? I have the same problem.
I'm using dropzone, $save->isFinished() returns false
nginx server

@braulioholtz
Copy link

I think the problem may be when the request is with loadbalancer, the files generated in the chunk folder are different, the solution was to disable in the config the value of name->use all to false
'chunk' => [ // setup for the chunk naming setup to ensure same name upload at same time 'name' => [ 'use' => [ 'session' => false, // should the chunk name use the session id? The uploader must send cookie!, 'browser' => false, // instead of session we can use the ip and browser? ], ], ],

@pionl
Copy link
Owner

pionl commented Aug 1, 2022

If the session changes then it is definitelly a problem :) Good find. Maybe default value should be session = false ?

@vmrfriz
Copy link

vmrfriz commented Apr 9, 2024

Same issue. I have many logs with this problem. I use php 8.1.27, DropZone 5.9.3, Laravel 8.40. When the last chunk (for example, 5 out of 5) is uploaded, the file assembly begins, even if not all chunks have been uploaded yet (for example, 4 out of 5).

It is the condition of loading the last chunk that is checked here.

protected function tryToBuildFullFileFromChunks()

I see the following error in the logs:

SplFileInfo::getType(): Lstat failed for /path/to/chunks/some-file-name.mp4-484aaeb2-4736-4340-a25c-bdf21b739e7f.10.part

Payload of the last request containing an error:

{
  "dzuuid": "62008064-10f1-4eed-b559-4bb02dcb5454",
  "dzchunkindex": "8",
  "dztotalfilesize": "122219582",
  "dzchunksize": "10000000",
  "dztotalchunkcount": "13",
  "dzchunkbyteoffset": "80000000",
  "_token": "********",
  "video": {
    "name": "some-file-name.mp4",
    "size": "0"
  }
}

idk how to solve this problem with code. This is the first time I've encountered chunks. Now I'm looking for the DropZone option to send the last chunk only after unloading all the others. Unsuccessfully

I will be grateful for any help 🙏

UPD: I found such a solution #91 (comment). It should work intuitively. I will write about the results – problem is still not solved

@osster
Copy link

osster commented Nov 8, 2024

Maybe would be useful for someone. Here is my working example from frontend side.

  async addLarge ({ commit, state }, file) {
    const size = 1024 * 1000
    const chunks = Math.ceil(file.size / size)
    const chanked = []
    for (let i = 0; i < chunks; i++) {
      chanked.push(file.slice(
        i * size, Math.min(i * size + size, file.size), file.type
      ))
    }
    if (chanked.length === 0) {
      return
    }
    let i = 0
    const t = chanked.length
    while (chanked.length > 0) {
      const form = new FormData()
      form.append('chunk', i)
      form.append('chunks', t)
      form.append('file', chanked.shift(), file.name)
      await this.$axios.post(
        'YOUR_URL',
        form
      )
        .then((res) => {
          // Do something
        })
        .catch((e) => {
          console.error(e.response)
        })
      i++
    }
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants