Comments (13)
@JeffBeltran I did manage to find a workaround that works quite well. I made a custom action with the following code:
class ExportExcel extends ExportToExcel implements WithHeadings
{
use InteractsWithQueue;
public function handle(ActionRequest $request, Action $exportable): array
{
$resource = $request->resource();
$filename = '/tmp/' . $resource::uriKey() . '-' . now()->format('Y-m-d') . '.xlsx';
$response = Excel::store(
$exportable,
$filename,
$this->getDisk(),
$this->getWriterType()
);
return Action::download(
Storage::disk($this->getDisk())->url($filename),
$this->getFilename()
);
}
public function fields()
{
return [];
}
}
This will upload the file to the tmp folder on S3 (so it is removed every 24 hours). Just change the folder location if you don't want it to be deleted. Then on the Nova resource, you can add the action like so:
(new ExportExcel())->withDisk('my-s3-disk')
from laravel-nova-excel.
I'm having the same issue on Laravel Vapor as there is no local filesystem. Is there a way to use the remote_disk
to temporarily store the file instead of the local disk?
from laravel-nova-excel.
Hi Bobby,
The multi-server setup should work for the Laravel Excel Nova package as well.
Please refer to the Laravel Excel documentation about multi-server setup to see how to set things up.
from laravel-nova-excel.
That is perfect! Thanks for sharing that part in the documentation! I have everything up and running now ;)
from laravel-nova-excel.
Sorry I had to reopen this issue again! So I thought I had this working locally, but on my acceptance environment it's still failing. The S3 setup is only working whenever you use queues. But in my case I want to use it without queues as well. Is there a possibility for this?
Updating the local_path
doesn't work for me at this point, since we have multiple machines and we don't know where the container is running. Sharing a path isn't going to work as well!
I can make a PR for always being able to use S3, but not sure if you want something like this.
from laravel-nova-excel.
Perhaps we could store the "download" file on the temporary disk. In your case that would go to S3. The api to the ExcelController then downloads it via the temporary disk instead of just calling the full path that is passed. (Sounds a lot better anyway actually haha :) )
Feel free to PR it! Thanks!
from laravel-nova-excel.
I'm not sure how to handle this since the package always sends back the url of the download to the frontend. How would I save the file to own storage and send that url back from the action in Nova?
I will look into making a PR for everyone to use a different local path, queue or not
from laravel-nova-excel.
Instead of sending back the url of the download, send back the path and disk where it's stored. Then in the controller call do the actual download based on those 2 instead of the given full path.
from laravel-nova-excel.
So that basically means overriding the controllers from the laravel-excel-nova package right? It seems to be the only solution at this point.
I also looked in being always able to store temp files on another disk, but that needs some more work in the core laravel-excel package. Looked simpel at first sight hehe!
from laravel-nova-excel.
How about using a custom action and using ExportToExcel for storing it to a disk of your choice? See Full control
from laravel-nova-excel.
@jbardnz if you find a solution would you ping me please, same issue
from laravel-nova-excel.
wow thanks man, my brain is dead so i'll save this for the morning. thanks in advance :D
from laravel-nova-excel.
@jbardnz Thank you!
Saved me loads of time! Worked like a charm with Vapor.
I had to remove the leading / in /tmp/
. But might be because of my .env file.
from laravel-nova-excel.
Related Issues (20)
- Tip: Getting this to work on Google cloud engine HOT 1
- Enqueue export on demande HOT 1
- Method Laravel\Nova\Fields\FieldCollection::filterForIndex does not exist. HOT 1
- QueuedExport doesn't allow softDeleted data HOT 10
- FileNotFound after upgrade HOT 3
- [BUG] ExportResourceActionRequest::forAllMatchingResources in Nova 4.0 HOT 4
- QUESTION: how to include columns and extra rows from related resources HOT 10
- [BUG] Error in Nova 4.0 using default User Resource - Too few arguments HOT 8
- [QUESTION] How to export a nova resource to excel WITHOUT actions?
- [BUG] Error in Nova 4 when trying to use actions in lenses HOT 1
- [PROPOSAL] Implement strict null comparison
- "Select all"-download doesn't work HOT 9
- [BUG] MemoryCache class methods incompatible with Psr\SimpleCache\CacheInterface HOT 2
- Excel is failed to download in laravel nova HOT 2
- Cannot download excel sheet in forge server HOT 2
- [BUG] Crash with Nova 4.24.0; parameter type declaration mismatch in withName HOT 3
- Belogs to
- Select All via Relationship table Exports Entire Resource
- How to access the Resource/Model in the Query? HOT 1
- [BUG] No longer works with the latest version of Laravel Nova (4.32.9) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-nova-excel.