Skip to content
New issue

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

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

Already on GitHub? # to your account

Change filePath to real path if it's an upload #4132

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

isaacdew2
Copy link
Contributor

@isaacdew2 isaacdew2 commented May 15, 2024

Please take note of our contributing guidelines: https://docs.laravel-excel.com/3.1/getting-started/contributing.html
Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.

1️⃣ Why should it be added? What are the benefits of this change?
The current state breaks cases where the UploadedFile is not on a local disk such as S3. I discovered this issue in a project when using S3 for Livewire temporary files. Currently, one must do $myImport->import($uploadedFile->getRealPath()) instead of $myImport->import($uploadedFile) when using S3 for temporary files.

2️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.
No.

3️⃣ Does it include tests, if possible?
No. I'm not sure how to add tests for this without a remote disk connection. If there's a way let me know!

4️⃣ Any drawbacks? Possible breaking changes?
There shouldn't be. It's a small change and for local UploadFile instances it should work exactly as it did before.

5️⃣ Mark the following tasks as done:

  • Checked the codebase to ensure that your feature doesn't already exist.
  • Take note of the contributing guidelines.
  • Checked the pull requests to ensure that another person hasn't already submitted a fix.
  • Added tests to ensure against regression.

6️⃣ Thanks for contributing! 🙌
Thank you for building an awesome package!

@patrickbrouwers patrickbrouwers merged commit dedf198 into SpartnerNL:3.1 Jun 3, 2024
18 checks passed
@patrickbrouwers patrickbrouwers mentioned this pull request Jun 3, 2024
1 task
@timsinakiran
Copy link

This breaks existing implementations. I had to revert to 3.1.55. With 3.1.56 the uploaded file would not be found at all.

@isaacdew2
Copy link
Contributor Author

This breaks existing implementations. I had to revert to 3.1.55. With 3.1.56 the uploaded file would not be found at all.

Hmm...that's odd. The behavior before for UploadedFile was to immediately try to read it from the local filesystem. This change just reads it from the local filesystem if realpath is not false (it exists on the local disk), otherwise, it uses Laravel's
file storage disk. Is the uploaded file stored locally? Maybe realpath is not the right function to use here?

@howdu howdu mentioned this pull request Sep 5, 2024
4 tasks
@howdu
Copy link

howdu commented Sep 5, 2024

@isaacdew2 we are also experiencing issue with your changes when specifying a 'disk' it's now using the absolute path to read from the storage. Please see my PR to see if that works for you too.

@SanderMuller
Copy link
Contributor

SanderMuller commented Sep 6, 2024

This also breaks our use case, importing to S3 via disk.

@patrickbrouwers maybe the best course would be to revert this change. Then @isaacdew2 can stay on the current tag while the new tag returns a working state for existing users. In the meanwhile a new PR can be created and tested to get it working for everyone. Especially since reverting to 3.1.55 means also downgrading to before the security patch of 3.1.57

@patrickbrouwers
Copy link
Member

@SanderMuller can you check if #4200 fixes your use case too?

@SanderMuller
Copy link
Contributor

@patrickbrouwers it fixes it, yes. But I'm not sure if it still works for @isaacdew2 given his #4200 (comment)

@isaacdew2
Copy link
Contributor Author

This also breaks our use case, importing to S3 via disk.

@patrickbrouwers maybe the best course would be to revert this change. Then @isaacdew2 can stay on the current tag while the new tag returns a working state for existing users. In the meanwhile a new PR can be created and tested to get it working for everyone. Especially since reverting to 3.1.55 means also downgrading to before the security patch of 3.1.57

I tend to agree with @SanderMuller. Apologies for all of the headaches! I can create a PR to revert my change if that'd be helpful.

@patrickbrouwers
Copy link
Member

Let's do that and then work in the new PR on a fix for all solutions

isaacdew2 added a commit to isaacdew2/Laravel-Excel that referenced this pull request Sep 6, 2024
patrickbrouwers pushed a commit that referenced this pull request Sep 7, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants