Recently OpenCraft has needed to deal with a few blocks that needed to deal with assets. In some cases they simply needed a URL for displaying an image / video / audio and course authors would need to figure out a way to upload an asset somewhere and get the URL. While we could point them to the course file upload page and how to get URLs for the assets stored there we wondered if we would improve this experience somewhat by having some kind of common asset-management mechanism for XBlocks.
There is one particular mechanism that we are considering which seems like it can be implemented with relative ease. In brief the authoring MFE will add a new file browser interface which can be heavily based on the existing file management page. An XBlock will be able to open this page, which can then display the available assets and allow uploading new one. The page will show a UI to allow selecting one or more files and pass these back to the XBlock using `postMessage`.
We prototyped this and it works well enough. Here is a video of the prototype:
Getting this very basic prototype running took very little time, however there is a lot more that would need to be done to make it work better:
- The UI should hide the header footer and adapt itself as a file picker in this mode.
- There should be options via query parameters to allow single or multi-file selection, and to filter by MIME type.
- The XBlock should pass its usage key etc so that context can be stored with the file and ti can be associated with the block.
- It should also be possible to embed this UI instead of opening a popup.
We’d love to see if this approach is something that could be more broadly useful or if it could potentially conflict with other effort in this area. The integraion here is pretty easy to swap out as well, it’s a simple message being passed from the MFE to the block, so it’s entirely possible to use a completely custom asset management solution as long as it can emit the same postmessage signal that the MFE does containing basic details about the file and its URL.