fix: playlist cover upload — POST /api/playlist/{id}/image FormData with JWT
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb337fd463
commit
1d318d052c
2 files changed
+6
-7
No files matched your search
@@ -505,13 +505,12 @@ async function editPlCoverSelected(input){
|
||||
const preview=URL.createObjectURL(file);
|
||||
document.getElementById('edit-pl-cover').innerHTML=`<img src="${preview}" style="width:100%;height:100%;object-fit:cover">`;
|
||||
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');
|
||||
|
||||
Reference in new issue
Block a user