-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
[Live][POC] alternate upload system #395
Conversation
Would it make sense to connect this behavior to https://glide.thephpleague.com perhaps? |
I suppose you mean for shrinking the preview images? Could the LazyImage component be used somehow? Maybe a |
First of all - I really like the direction outlined here. In fact this is in line with my initial ideas for #299 that got somewhere lost between countless implementation details. I would love to see this pushed forward or maybe somehow merged with live controller code from my PR to avoid solving the same problems twice :) I really like that you've chosen to save files to I have already solved implementation challenges to (at least partially) glue |
Agreed, good idea!
I've been hacking on an alternate-flysystem-api library that provides something similar. Hoping to circle back and iterate on this PR in the next few weeks. Hoping we can merge the work in #299 and I'm going to need help with the js. Still thinking on how to handle the
|
I thought about this subject for a while. I have worked both on Glide (https://github.com/thephpleague/glide) and Flysystem (https://github.com/thephpleague/flysystem) in part because I think these two libraries have a role to play for this. I have implemented many variants of an upload system in my projects and I have some ideas to share. I think this will quickly become larger than a "simple upload" system. We can probably achieve a "simple" version of an upload system at first (which this PR does wonderfully), but I do think we need to set up the proper structure right from the beginning to avoid being blocked when we will inevitably need to make it more generic. IMO the challenge here is to create a well-thought abstraction for uploading, storing and displaying files: an abstraction that is extensible enough (to allow for manipulation before storage/before display, to allow for storage locally/somewhere remote, ...) while providing all the features we want. From my experience, such abstraction needs to have several capabilities:
I'm thinking we may want to create a "UploaderInterface", and maybe have it in a dedicated component that the LiveComponent component could wire automatically when both are installed. Such LiveUpload component (name TBD) could then rely on Flysystem by default for storage, with a default local storage wired (https://github.com/thephpleague/flysystem-bundle), and maybe on Glide for image manipulation (so that it's easy to manipulate the image before storage and before display). I have been wanting to implement such features in Glide for a while now (thephpleague/glide#288 (comment)) and never had time to do it, because I didn't have the need to. If this PR opens the possibility of creating such component, I'd be glad to start working for real on a Glide version that would benefit such upload system. PS: I'm 100% fine with merging a simple version of the PR before starting the work on something more generic. However, we should be careful not to block ourselves with things we didn't anticipate. |
I'm all in for starting with contracts and building up from that. I think initial definition of I have this topic at the back of my head most of the time and some ideas and conclusions come and go, so I'll take my time this Friday to sit and write a draft of just this interface (without any implementation) and will open a separate PR with just that. We can then discuss the scope and shape of it. Once finalized we can start discussion whether we want a new component with default implementations and what other pieces of the puzzle it could fit in. I think if we do it right we might even want to promote it to |
I have created a PR #404 with not really innovative interface. IT probably lacks many things, but I think we need to start somewhere :) Creating another component for I have recently found out about Intervention Image v3 being in alpha. This library is rather slow in development, but it might be worth to take a look at the changes for Glide 3 :) |
Hello guys, |
Still on our minds. @Lustmored, @weaverryan and I have been stepping back to take a discuss how best to provide filesystem abstraction in a way that would help here. |
@kbond
There were some nasty Symfony-forms related things to overcome if you want to use this in combination with the form-trait. https://gist.github.com/veewee/471e35798761f1295482343972a468a7 |
Awesome, thanks @veewee. Will check out your gist. For a status update, @Lustmored and I are (slowly) working on an experiment to use zenstruck/filesystem (filesystem abstraction system based on flysystem) as the storage abstraction for this feature. @Lustmored recently added controller value resolvers for "files/images". We're hoping to try and reuse the attributes for a |
Closing in favor of #834 which is a better first step to achieve. |
Possible replacement/alternative to #299.
The idea here is to create an upload system similar to livewire:
LiveFile
object that extends HttpFoundation'sFile
(so file validations will work) but also has aurl()
method that returns/preview-url/unique_id.jpg
LiveFileHydrator
input[type=file]
onblur, we can upload the file to upload url above, take the returned filename(s), set it/them on the component, validate, and access the url (so we can show previews like livewire)LiveFile
's (ie send to s3 or whatever)live:cleanup-temp-files
command that deletes temp files older than x hours/days (can be scheduled on a cron)TODO: