fixed m3u file upload

This commit is contained in:
dekzter 2025-03-12 13:49:16 -04:00
parent d0c18a6787
commit fc244044e2
2 changed files with 18 additions and 5 deletions

View file

@ -479,13 +479,29 @@ export default class API {
}
static async addPlaylist(values) {
let body = null;
if (values.uploaded_file) {
body = new FormData();
for (const prop in values) {
body.append(prop, values[prop]);
}
} else {
body = { ...values };
delete body.uploaded_file;
body = JSON.stringify(body);
}
const response = await fetch(`${host}/api/m3u/accounts/`, {
method: 'POST',
headers: {
Authorization: `Bearer ${await API.getAuthToken()}`,
'Content-Type': 'application/json',
...(values.uploaded_file
? {}
: {
'Content-Type': 'application/json',
}),
},
body: JSON.stringify(values),
body,
});
const retval = await response.json();

View file

@ -23,10 +23,7 @@ const M3U = ({ playlist = null, isOpen, onClose }) => {
const [file, setFile] = useState(null);
const [profileModalOpen, setProfileModalOpen] = useState(false);
console.log(playlist);
const handleFileChange = (file) => {
console.log(file);
if (file) {
setFile(file);
}