This is related to both Webxdc and Delta Chat, but this seems like the better place to put it.
It would be very powerful if Webxdc apps could export files and media of any size directly into the chat only for the local client. Currently, the only way to embed files directly in chat is by using attachments, which typically have extremely tight file size restrictions (~25 MB) and use precious space on the relay. On the other hand, apps have access to “unlimited” space in the local system memory and localStorage.
When an app generates or receives a large file, it would be useful if it could then export the file to chat locally so the user can view and download it easily. It would appear like an attachment, where normal media embedding behavior applies (images/audio/video are playable inline). This way we can have big files in chat without using any server storage.
Proposal
Currently the only way Webxdc apps can interact with chat is by posting brief “info” messages with sendUpdate() or by uploading a file with sendToChat(). Both of these methods send out a message to all users, which demands server resources and is subject to size limits. I propose an API called exportFile() to match the existing importFiles() method. It would accept a filename and a blob/base64 similarly to sendToChat() and post the file in chat like an attachment (with the embedded player if it’s a media file). It should also visually indicate somehow that the file is local and no one else can see it. Maybe expand the app panel downward like a drawer and place exported files inside it like so:
Use cases
Large media
This proposal would allow large playable media files (100+ MB) to be accessible in chat, which is normally not possible. One example where this would be useful is davidsm10’s Sharer app. It allows large files (like videos) to be transferred in chat, but they can only be downloaded/viewed within the app after being received, which is less than ideal. It would be much more ergonomic if apps like this could post the received file out to the chat directly when the transfer is complete.
Saves and backups
An app might want to allow the user to save or back up something they’ve created locally, so this would allow the app to simply output the save/backup file into the chat.
Screenshots/renders
A game app might offer the option to take screenshots and dump them to the chat for easy download. Similarly, a graphical app could produce high resolution renders and then export them to chat as lossless PNGs.
Long-running apps
Persistent app state can be fragile if not designed robustly (even more so if state must be shared), and may be lost if the app is accidentally closed. An app that slowly processes many items over time (e.g. a batch image converter) could output the resulting files to the chat as it progresses, so even if the app crashes or is closed accidentally, the files completed before the app terminated are still preserved in chat.

