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

Work with Laravel #15

Open
hugomosh opened this issue Apr 4, 2015 · 3 comments
Open

Work with Laravel #15

hugomosh opened this issue Apr 4, 2015 · 3 comments

Comments

@hugomosh
Copy link

hugomosh commented Apr 4, 2015

This is a nasty code but It work for me for an AngularJs and Laravel 5 integration. I am just happy and want to share it for sme. It is a copy from one post here but modified.

    public function getSubirArchivo($declaracion) {
        error_log('Documento 22');

        $request = new \Flow\Request();
        $config = new \Flow\Config(array(
            'tempDir' => './chunks_temp', //With write access
        ));

        $file = new \Flow\File($config, $request);
        $response = Response::make('', 200);

        $destination = './archivos/' . $declaracion . '_' . $request->getFileName();
        if ($_SERVER['REQUEST_METHOD'] === 'GET') {
            error_log('Documento GET');
            if (!$file->checkChunk()) {
                error_log('Documento GET2');
                return Response::make('', 204);
            }
        } else {
            if ($file->validateChunk()) {
                $file->saveChunk();
                error_log('Documento VaLido !!!');

            } else {
                error_log('Documento INVALIDO');
                // error, invalid chunk upload request, retry
                return Response::make('Error in chunck', 400);
            }
        }
        if ($file->validateFile() && $file->save($destination)) {
            error_log('EXITO!');
            $response = Response::make('pass some success message to flow.js', 200);
        }
        return $response;
    }
@citosid
Copy link

citosid commented Apr 28, 2017

@hugomosh we are using the same thing you have here, but with PHP 7, and we are seeing very weird things.

We have nginx in front of our php, using php-fpm, but we noticed that it has to retry a lot of chunks several times before uploading the files... after hours of debugging and testing, we found that if we add a sleep(2); it just works... so, we were wondering, have you experience the same thing? Do you have any clue of what could be the problem?

@hugomosh
Copy link
Author

@citosid sorry, I don't longer work in the project where I used it.

@citosid
Copy link

citosid commented May 5, 2017

Thanks @hugomosh... it turned out to be a problem with fpm and permissions... after setting the permissions of the folders you need to restart fpm, otherwise it will not work.

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

2 participants