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

$fileReceived->isFinished() is never called when uploading the file from a different site #158

Open
tato-rj opened this issue Sep 13, 2023 · 4 comments

Comments

@tato-rj
Copy link

tato-rj commented Sep 13, 2023

What steps will reproduce the problem?

I am using resumable.js to upload the file. The resumable.js is in one website, and the backend chunk-upload is in another (it all works well if both are on the same site).

What is the expected result?

When both frontend and backend are in the same site, it all works. The chunks are created and the $fileReceived->isFinished() is triggered as expected.

What do you get instead?

When the file is sent from a different site (which is the setup I need), the chunks are created but the $fileReceived->isFinished() never gets called.

Additional info

When logging the $fileReceived->handler()->getPercentageDone(), I noticed something interesting:
This is the log when all works well (both frontend and backend are in the same site)

[2023-09-13 22:35:01] local.DEBUG: Percentage done: 30  
[2023-09-13 22:35:01] local.DEBUG: Percentage done: 30  
[2023-09-13 22:35:01] local.DEBUG: Percentage done: 30  
[2023-09-13 22:35:01] local.DEBUG: Percentage done: 60  
[2023-09-13 22:35:01] local.DEBUG: Percentage done: 60  
[2023-09-13 22:35:01] local.DEBUG: Percentage done: 60  
[2023-09-13 22:35:01] local.DEBUG: Percentage done: 80  
[2023-09-13 22:35:01] local.DEBUG: Percentage done: 80  
[2023-09-13 22:35:01] local.DEBUG: Percentage done: 90  
[2023-09-13 22:35:01] local.DEBUG: Percentage done: 100  

And here is the log when it doesn't (frontend and backend are in different sites)

[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  
[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  
[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  
[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  
[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  
[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  
[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  
[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  
[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  
[2023-09-13 22:23:55] local.DEBUG: Percentage done: 10  

It seems to get stuck at 10% but stops after the same amount of iterations. The chunks are created as expected.

Q A
This Package Version 1.5
resumable.js 1.0.3
Laravel Framework Version 9.19
PHP version 8.0
Operating system Darwin iMac.local 22.6.0
@tato-rj tato-rj changed the title $fileReceived->isFinished() is never called when sending filed from a different site $fileReceived->isFinished() is never called when uploading the file from a different site Sep 13, 2023
@tato-rj
Copy link
Author

tato-rj commented Sep 13, 2023

I just switched these from true to false and it now works. Session is now false and Browser is now true. Can anybody explain why? Can I keep it this way?

'use' => [
    'session' => false, // should the chunk name use the session id? The uploader must send cookie!,
    'browser' => true, // instead of session we can use the ip and browser?
],

@nerg4l
Copy link

nerg4l commented Sep 18, 2023

In case of session the session id is used as part of the identifier.

if ($useSession) {
$array[] = Session::getId();
}

When browser is used, then the md5 hash of the user IP and user agent is used.

if ($useBrowser) {
$array[] = md5($this->request->ip().$this->request->header('User-Agent', 'no-browser'));
}

The session ID is probably changes every time because the browser blocks the set cookie or just simply does not sends it because the request is cross-domain.

It is better to use the session identifier because the IP and the user agent might be empty and can be the same between users.

@tato-rj
Copy link
Author

tato-rj commented Sep 20, 2023

Got it, thanks for the reply. Is there a specific cookie I should be sending from the sender app to the receiver?

@BilalTariq01
Copy link

BilalTariq01 commented Oct 6, 2023

@tato-rj same issue but setting browser true and session false in config not working for me

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

No branches or pull requests

3 participants