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

Problem Accessing Files Saved on Storage in Laravel with Flysystem #1833

Closed
l-netcaring opened this issue Nov 22, 2024 · 3 comments
Closed

Comments

@l-netcaring
Copy link

l-netcaring commented Nov 22, 2024

Versione Laravel: 8.81
Versione PHP: 7.4.27
Driver e versione del database: MySQL 8
league/flysystem: 1.1.9
Descrizione:
I am facing a problem in the context of a Laravel application related to uploading and managing files through the built-in storage system (Filesystem). The problem manifests as follows:

Upload Operations and Generated Path:

  • The store method is used to save a file to the storage/app/imports directory.
  • The path generated by the store method is correctly logged, indicating that the file was presumably saved with a hash name in the desired location.

example of printed log
[2024-11-22 12:29:25] prod.INFO: Path generato: imports/aWZzHU9JIQApMGomxFavQ1MI7fxWn7tnWqt29R5U.xlsx

When the code tries to access the saved file using the generated path, the system (flysystem) throws an exception. This implies that the file is not found or the path passed is not recognized correctly.

  • The path check ($path) seems correct, and the logs indicate that the file exists at the time of upload.
  • However, the storage system throws an exception when trying to interact with the file.

` $file = $request->file('file');
$path = $file->store('imports');
$nome_file = $file->hashName();
$nome_file_no_ext = basename($nome_file, '.xlsx');

    try {
        VoucherImport::dispatch($nome_file_no_ext, $request->id_account, $request->id_agenzia,$path);
    } catch (\Throwable $th) {
        if ($th->getCode() == 999)
            return $this->getErrorResponse($th->getMessage());
        else throw $th;
    }`

League\Flysystem\FileNotFoundException: File not found at path: imports/aWZzHU9JIQApMGomxFavQ1MI7fxWn7tnWqt29R5U.xlsx

@frankdejonge
Copy link
Member

Flysystem 1 is very old and no longer supported, please upgrade to version 3.

@l-netcaring
Copy link
Author

My laravel version is 8, version 3 is not supported

@frankdejonge
Copy link
Member

Sorry to hear. At some point I needed to stop support for V1 and that was already some time ago.

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