Allow apps to export large files to local chat only

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.

Just a note: if you have multi-device disabled and send anything to your saved messages whatever you send is only saved locally only, no sent anywhere.

I suppose this means that if an app used sendToChat() to send files to saved messages, it would incur relay traffic if the user has multiple devices set up. That’s unfortunate because it’s almost a solution. It could work if sendToChat() had a localOnly flag to ensure the message won’t be broadcast.

I would say that the “Export Attachment” buttons that shows up when you sendToChat() is good enough.

Out of the listed use cases it seems to me that the only one that really benefits from the proposal is “large file support”, Large files support [integrate with large file sending solutions and workarounds], which, IMO, should be solved differently from what’s proposed here.

I can see a more feasible and less confusing way to achieve the desired “ease of access to the exported files”: when exporting a file with “Export Attachment”, remember the file path, and then display the list of exported files somewhere in maybe a separate dialog / screen, behind the three-dot menu.

It’s true, that does come close to what I want. The only downside is that the exported attachment file must remain in the exact export path or Delta Chat will lose track of it.

Normally if you send a video attachment, even if it’s too large to be sent by the selected relay, it will remain playable in your local chat even if you move the original source file. This suggests that Delta Chat copies the file into an internal database as part of the chat history.

It would be nice if Webxdc apps could access this functionality, essentially by saying “store this file in the chat history, but don’t send it to anyone else”.

While certainly useful, I don’t think the large files solution you linked to fits with this proposal’s goal. Using external file hosting services just to output files to exclusively to oneself seems like overkill and unnecessarily slow.

Having exported content visibly tied to the app that generated it seems clearer to me than having to click through additional dialogs to access it, which is no different from having to open the app to access its content. It also automatically organizes the content by app instance and weaves it into the story told by the chat history for context (e.g. I can recognize that this file was created by me and a friend X for Y reason).

Currently app instances in chat are visually identical and indistinguishable so there’s no way to tell what was done in a particular app instance without manually opening it. Allowing some form of inline embedding of exported files would at least allow the user to visually recognize what an app was/is being used for without going through unnecessary extra steps.