| | |
| | | /* |
| | | * To change this license header, choose License Headers in Project Properties. |
| | | * To change this template file, choose Tools | Templates |
| | | * and open the template in the editor. |
| | | Mediazentrale - Personal Media Center |
| | | Copyright (C) 2021 Ulrich Hilger |
| | | |
| | | This program is free software: you can redistribute it and/or modify |
| | | it under the terms of the GNU Affero General Public License as |
| | | published by the Free Software Foundation, either version 3 of the |
| | | License, or (at your option) any later version. |
| | | |
| | | This program is distributed in the hope that it will be useful, |
| | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| | | GNU Affero General Public License for more details. |
| | | |
| | | You should have received a copy of the GNU Affero General Public License |
| | | along with this program. If not, see <https://www.gnu.org/licenses/>. |
| | | */ |
| | | package de.uhilger.mediaz.api; |
| | | |
| | |
| | | if(files != null) { |
| | | for(File file : files) { |
| | | StorageFile sf = new StorageFile(); |
| | | sf.setName(file.getName()); |
| | | String fname = file.getName(); |
| | | sf.setName(fname); |
| | | if(file.isDirectory()) { |
| | | sf.setTyp(StorageFile.TYP_FOLDER); |
| | | } else { |
| | | sf.setTyp(StorageFile.TYP_FILE); |
| | | if(fname.endsWith(".mp3")) { |
| | | sf.setTyp(StorageFile.TYP_AUDIO); |
| | | } else if(fname.endsWith(".mp4") || fname.endsWith(".m4v")) { |
| | | sf.setTyp(StorageFile.TYP_VIDEO); |
| | | } else { |
| | | sf.setTyp(StorageFile.TYP_FILE); |
| | | } |
| | | } |
| | | list.add(sf); |
| | | } |
| | | } |
| | | //Gson gson = new Gson(); |
| | | //String json = gson.toJson(fileNames); |
| | | String json = jsonWithCustomType(list, "Medialiste"); |
| | | logger.fine(json); |
| | | e.sendResponseHeaders(200, json.length()); |