files_texteditor icon indicating copy to clipboard operation
files_texteditor copied to clipboard

Cannot edit powershell file (will be downloaded instead)

Open BornToBeRoot opened this issue 7 years ago • 1 comments

Cannot edit powershell scripts... they should be editable according to this list: https://github.com/nextcloud/files_texteditor/blob/cfa393018075029e9486bda604456acee0b6c45f/js/editor.js#L528

Steps to reproduce

  1. Upload a PowerShell script (.ps1-file)
  2. Click on it

Expected behaviour

Editor should open...

Actual behaviour

File is downloaded...

Server configuration

Operating system: CentOS 7.5

Web server: Apache

Database: MariaDB

PHP version: 7.1

Nextcloud version: (see Nextcloud admin page) 13.0.5

Where did you install Nextcloud from: nextcloud.com --> download archive

BornToBeRoot avatar Aug 28 '18 19:08 BornToBeRoot

You can set file extensions to treat as text files by mapping the file extension to a mime type in Nextcloud. This is not defined by Texteditor but in Nextcloud.

  1. Create (or edit) a file named <nextcloud>/config/mimetypemapping.json and add your mapping, eg.:
{
  "ps1" : ["text/code"]
}
  1. Update Nextcloud's mapping (run with your www-data user):
$ php occ maintenance:mimetype:update-js
  1. Rescan your files to apply changes to existing files (run with www-data user):
$ php occ files:scan --all

References :

  • https://docs.nextcloud.com/server/20/admin_manual/configuration_mimetypes/index.html
  • https://help.nextcloud.com/t/mimetype-mapping-problem/8365/2

biguenique avatar Jan 31 '21 02:01 biguenique