Skip to content

Recognize further file extensions as text files (to be opened in the "in-app" text editor) #7098

Description

@AndyScherzinger

This is a clone of nextcloud/android#1756 which asked for further file extensions to be opened in the Android client's in-app viewer. So for consistency reasons if this is to be implemented it should be implemented across the eco system as-in webUI and clients (at least Android and iOS)

Expected behaviour

  1. Create a file text with extension .adoc, .rc, .conf, .gitignore, .todo, .cfg, or without any extension
  2. Click on the file
  3. File opens in the webUI text editor

Actual behaviour

.adoc, .rc, .conf, .gitignore, .todo, .cfg are treated as generic file

Environment data

Android version: 5.1.1

Stock or customized device OS: Customized

Nextcloud Android app version: 2.0.1, from FDroid

Nextcloud server version: 12

Activity

  1. MorrisJobke commented on Nov 7, 2017

    @MorrisJobke
    Member

    @icewind1991 @rullzer Ideas for this?

  2. j-ed commented on Nov 7, 2017

    @j-ed
    Contributor

    Wouldn't be possible to automatically identify the file type based on its mime-type instead of pinning it to file extensions? It was a common trick in the past to fake a file extension to bypass email block list etc.
    See: https://stackoverflow.com/questions/457797/best-way-to-recognize-a-filetype-in-php

  3. MorrisJobke commented on Nov 7, 2017

    @MorrisJobke
    Member

    Wouldn't be possible to automatically identify the file type based on its mime-type instead of pinning it to file extensions? It was a common trick in the past to fake a file extension to bypass email block list etc.

    The fileinfo command is used as fallback, because it is usually a lot slower and the file needs to be loaded into memory for this. Thus it is not that performant if you need to detect the mime type for a lot of files in a batch. But for uploads this should be fine. On the other side it is then bad to use one approach for file uploads but another one for files:scan. 😕

    cc @icewind1991

  4. j-ed commented on Nov 8, 2017

    @j-ed
    Contributor

    @MorrisJobke Thank you for the explanation. I agree, for uploading single files it might be justified to spend that additional time to evaluate the correct mime-type but for batch runs it might be better to rely on the database information or a different approach need to be find.
    Due to the fact that all kind of house keeping tasks are running in the background of Nextcloud, wouldn't it make sense to also double-check the mime-type of newly added files by e.g. executing the external file-command. The command is relatively fast and could also run on whole directories - just an idea.

  5. AndyScherzinger commented on Nov 8, 2017

    @AndyScherzinger
    MemberAuthor

    But for uploads this should be fine. On the other side it is then bad to use one approach for file uploads but another one for files:scan.

    Besides that looking at the client we do not receive mime type information from the server that is why the clients also rely on the file extension to predict the mime type.

  6. j-ed commented on Nov 8, 2017

    @j-ed
    Contributor

    @AndyScherzinger From what I've seen mime type information exist for all files on the server. Wouldn't it make sense to enhance the used API so that that piece of information is transferred too?

  7. AndyScherzinger commented on Nov 8, 2017

    @AndyScherzinger
    MemberAuthor

    @j-ed can't tell for the server part and yes having this info transferred from the server would help since we could (to some extend) drop mime-type calculation on the client(s) afaik the mime type information (at least via file extension) is the same on webUI and Android client. So if the webUI thinks a file is text-based than the Android client should do so too (if file extension based of course).

  8. tobiasKaminsky commented on Nov 8, 2017

    @tobiasKaminsky
    Member

    Besides that looking at the client we do not receive mime type information from the server that is why the clients also rely on the file extension to predict the mime type.

    We do get the mimetype:
    Getting from webdav to RemoteFile:
    https://github.com/nextcloud/android-library/blob/master/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java#L167

    From RemoteFile to OCFile:
    https://github.com/nextcloud/android/blob/8fef61ea93fb1307d431de1d594b473f1f6e4b2d/src/main/java/com/owncloud/android/utils/FileStorageUtils.java#L222-L222

    Were do we rely on the file extension? Maybe only on local files?

  9. AndyScherzinger commented on Nov 8, 2017

    @AndyScherzinger
    MemberAuthor

    Were do we rely on the file extension? Maybe only on local files?

    We always do for Android, see FileListListAdapter for example

  10. tobiasKaminsky commented on Nov 8, 2017

    @tobiasKaminsky
    Member

    Then we should adapt this: use mimeType from server as often as possible and rely on the extension only as fallback.

  11. AndyScherzinger commented on Nov 8, 2017

    @AndyScherzinger
    MemberAuthor

    Sounds good to me for Android 👍

    @nextcloud/ios how is this handled in the iOS client?

  12. marinofaggiana commented on Nov 9, 2017

    @marinofaggiana
    Member

    I use the UTI, but if possible the mimeType from server is better !

  13. Spartachetto commented on Nov 13, 2017

    @Spartachetto

    I hope not to derail the discussion but, as you are considering to extend the files recognized as some that could be open via text editor, I'd like to remember the proposal of other extensions.

    Look here (nextcloud/files_texteditor#16) and here (nextcloud/files_texteditor#15) for different syntax files which could be nice to open.

    Thank you

  14. ghost removed
    staleTicket or PR with no recent activity
    on Jun 12, 2019
  15. szaimen commented on May 21, 2021

    @szaimen
    Contributor

    I'm closing this issue due to inactivity. Please reopen if you still want to implement this.

  16. szaimen commented on May 27, 2021

    @szaimen
    Contributor

    I was at least able to open .conf files with the built in text editor. So I think this is at least partially implemented.

  17. tobiasKaminsky commented on May 27, 2021

    @tobiasKaminsky
    Member

    Also on Android with built in text editor?

  18. szaimen commented on May 27, 2021

    @szaimen
    Contributor

    Yes

  19. szaimen commented on May 27, 2021

    @szaimen
    Contributor

    Tough I wonder why this is in the server repository if it is an android ticket? 🤔

  20. Spartachetto commented on May 28, 2021

    @Spartachetto

    @szaimen this issue pops out several times in seemingly unrelated subjects.
    I think that even the discussion in Text app about non destructive editing (nextcloud/text#439 ) could be considered as related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions