From 1d318d052c85b330a3504d0542963faf7e959f46 Mon Sep 17 00:00:00 2001 From: Honey Date: Sun, 26 Apr 2026 01:44:23 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20playlist=20cover=20upload=20=E2=80=94=20?= =?UTF-8?q?POST=20/api/playlist/{id}/image=20FormData=20with=20JWT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirmed endpoint pattern from Navidrome API contract (artist/:id/image). FormData field 'image' + X-Nd-Authorization Bearer token. Bump SW ns-v36. Co-Authored-By: Claude Sonnet 4.6 --- app.js | 11 +++++------ sw.js | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index 436f397..8e48b5c 100644 --- a/app.js +++ b/app.js @@ -505,13 +505,12 @@ async function editPlCoverSelected(input){ const preview=URL.createObjectURL(file); document.getElementById('edit-pl-cover').innerHTML=``; try{ - const imageData=await new Promise((res,rej)=>{const r=new FileReader();r.onload=()=>res(r.result);r.onerror=rej;r.readAsDataURL(file);}); const token=await ndAuth(); - const pl=_currentPlaylist; - const res=await fetch(`${cfg.url}/api/playlist/${pl.id}`,{ - method:'PUT', - headers:{'X-Nd-Authorization':'Bearer '+token,'Content-Type':'application/json'}, - body:JSON.stringify({name:pl.name,comment:pl.comment||'',public:!!pl.public,imageData}) + const form=new FormData();form.append('image',file,file.name); + const res=await fetch(`${cfg.url}/api/playlist/${_currentPlaylist.id}/image`,{ + method:'POST', + headers:{'X-Nd-Authorization':'Bearer '+token}, + body:form }); if(!res.ok)throw new Error(res.status); toast('Cover aktualisiert'); diff --git a/sw.js b/sw.js index c5ff3b0..95d3357 100644 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -const CACHE = 'ns-v35'; +const CACHE = 'ns-v36'; const PRECACHE = ['/', 'index.html', 'styles.css', 'app.js', 'manifest.json', 'icon.svg']; const SKIP_PATHS = ['/rest/stream', '/rest/download', '/config.js'];