Hello,
Iām having an issue opening CSV files in the app on Nextcloud.
Error message: {āresponseā:āerrorā,āmsgā:ā"text/csv" MIME type is not supported.ā}
Iāve added ātext/csvā to Apacheās mime.conf, but it didnāt solve the problem.
How can I resolve this issue?
(function() {
if (OCA.Files && OCA.Files.Sidebar) {
var CsvTabView = function(el) {
this.$el = $(el);
this.update = function(fileInfo) {
if (fileInfo) {
this.$el.html('<div class="metadata-tab-view csv-metadata"><p>'
+ t('metadata', 'CSV loading')
+ '</p></div>');
this.loadCsvData(fileInfo);
}
};
this.loadCsvData = function(fileInfo) {
var url = OC.generateUrl('/apps/metadata/get');
var data = {source: fileInfo.path + '/' + fileInfo.name};
var self = this;
$.ajax({
type: 'GET',
url: url,
data: data,
dataType: 'text',
success: function(csvData) {
self.processCsvData(csvData);
},
error: function() {
self.$el.find('.csv-metadata').text(t('metadata', 'CSV not loading'));
}
});
};
this.processCsvData = function(csvData) {
var lines = csvData.split('\n');
var output = $('<div>').addClass('csv-output');
if (lines.length > 0) {
output.append($('<p>').text('ķ¤ė: ' + lines[0].trim()));
} else {
output.text(t('metadata', 'CSV .'));
}
this.$el.find('.csv-metadata').empty().append(output);
};
};
OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab({
id: 'metadata-csv',
name: t('metadata', 'CSV'),
icon: 'icon-details',
mount: function(el, fileInfo, context) {
var tabView = new CsvTabView(el);
this._tabView = tabView;
tabView.update(fileInfo);
},
update: function(fileInfo) {
this._tabView.update(fileInfo);
},
destroy: function() {
this._tabView = null;
},
enabled: function(fileInfo) {
return fileInfo && !fileInfo.isDirectory() && fileInfo.mimetype === 'text/csv';
}
}));
}
})();