Extend the behaviour of the media picker #6874
-
For my current project we have the requirement to be able to upload a zip(from an external party) extract the zip, apply some logic to the contents and then show it(like a zip again) in the media picker. The most elegant solution in my opinion would be to extend the behaviour of the media picker, check for the file extension and if its zip and it contains Is this something that can be done? Or would it be better to for example add a custom upload module where they can upload there contents? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
So i've found the IMediaCreatingEventHandler. I'm going to experimented with that a bit and update this discussion with my new findings |
Beta Was this translation helpful? Give feedback.
-
Yes, the However that handler expects to mutate the incoming stream, possibly to a different format, or size, and return a new stream and filename. So it will be a little trickier, as from what you say, you want to extract the contents of the zip archive, and store those contents in a folder. It should be possible, but you will still have to return a stream from the handler as well, and your handler will probably have to internally resolve the filestore in order to create more entries / folders from the zip archive. In terms of what you will see in the media library, it will be whatever files you end up creating. But if you have created multiple files from one archive, and / or extra folders, they won't be visible until you refresh the library. I would suggest you may find it easier to writing a small admin controller that injected the A custom recipe step might also be an option. It depends how many of these files there are, and how they are produced. |
Beta Was this translation helpful? Give feedback.
-
I'll close this one and post other questions i have in different discussions. Thanks for the help, this definitely set met on the right track. |
Beta Was this translation helpful? Give feedback.
Yes, the
IMediaCreatingEventHandler
maybe the place to start.However that handler expects to mutate the incoming stream, possibly to a different format, or size, and return a new stream and filename.
So it will be a little trickier, as from what you say, you want to extract the contents of the zip archive, and store those contents in a folder.
It should be possible, but you will still have to return a stream from the handler as well, and your handler will probably have to internally resolve the filestore in order to create more entries / folders from the zip archive.
In terms of what you will see in the media library, it will be whatever files you end up creating.
But if you have created…