-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Is there an existing issue or discussion for this?
- I have searched the existing issues & discussions
Primary Information
docman: 1.2.0Steps to Reproduce
Persist access to Termux directory (content://com.termux.documents/tree/...).
Obtain a DocumentFile for the target folder.
Call createFile with a name that includes an extension and minimal content:
Inspect the returned object and subsequent get():
name is "new_file" (no .html)
type is a text MIME (likely text/html), file exists and is readable/writable.
Sample from app-level entity wrapper:
canCreate=false canDelete=true canRead=true canWrite=true exists=true isFile=true name="new_File (2)" type="text/html" // inferred, not always visible in wrapper output uri=content://com.termux.documents/...
Expected Behavior
DocumentFile.name preserves the requested extension (e.g., "new_file.html") or at least exposes both:
the provider’s display name (which may omit the extension), and
a computed filename that includes an extension derived from MIME (or the requested name).
Current/Actual Behavior
On Termux’s provider only, name omits the extension (e.g., "new_file").
On device storage provider, name preserves the extension.
Code sample
final dir = await DocumentFile.fromUri('content://com.termux.documents/tree/...');
final created = await dir?.createFile(
name: 'new_file.html',
content: '',
);
print(created?.toMap());
Screenshots or Video
Debug Information, Logs
Logs / Debug information
[Paste your logs here]Possible Solution
This appears to be provider behavior: Termux may “canonicalize” the display name based on MIME and drop the extension.
However, docman exposes only a single name (provider display name). This makes extension-based logic and UI incorrect for providers that strip extensions.
docman currently asserts that either content or bytes must be provided; we pass minimal content to create empty files. This requirement is fine, but it doesn’t affect the stripping behavior.
Suggested solutions
API enhancement options (non-breaking behavior preferred):
Expose both displayName (raw provider value) and fileName (computed: append extension inferred from MIME if missing).
Expose mimeType directly on DocumentFile so apps can compute the extension reliably when name lacks one.
Alternatively, add an optional mimeType parameter to createFile so callers can explicitly control MIME and potentially influence provider naming.
Documentation:
Document that some providers (like Termux) may omit extensions in display names, and recommend using MIME to compute a user-facing filename.