Open HenryJian opened 5 years ago
For case 1, we can generate a temporary file name: share
123456 .txt
For case 2, we can append the text file contents into a single string, and truncate. This keeps with the existing Web Share design of the text field being a single string.
Truncation occurs if method=GET
. We can add a warning to the spec (PR).
The current WST specs distinguishes between sharing a text file (WST v2) and sharing naked text (WST v1). However, Android doesn't make such distinction. An apk with a
<data android:mimeType="text/plain"/>
inside its<intent-filter>
will respond to both text file sharing and naked text sharing.This causes problems for installed web apps on Android (through "add to home screen" on Chrome):
WST handles text files but not naked text: When a user shares naked text, the installed web app shows up in the list of share targets, , but it won't do anything because WST isn't expecting naked text.
WST handles naked text but not text files: Similarly, when a user shares text files, the installed web app shows up in the list of share targets, but it won't do anything because WST isn't expecting text files.
One solution to this is the user agent convert between text files and naked text behind the scene. For case 1, user agent writes the naked text to a text file. Caveat: filename will be empty. For case 2, user agent reads the file to get the naked text. Caveats: First, if user shares multiple files, form data/url search param will have multiple entries with the same "share-text" key. Thus, on the receiving end, form_data.get("share-text") or url_search_param.get("share-text") will return an array, instead of a string. Second, if data is encoded in url search parameter and user shares a big file, we may need to truncate file content because of url size limit