fix: playlist cover upload via PUT /api/playlist/{id} with base64 imageData
Navidrome (react-admin) expects image as base64 data URL in JSON body, not as a raw binary POST to /image endpoint. Bump SW to ns-v35. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
16f4f03474
commit
cb337fd463
2 files changed
+7
-5
No files matched your search
@@ -505,11 +505,13 @@ 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 res=await fetch(`${cfg.url}/api/playlist/${_currentPlaylist.id}/image`,{
|
||||
method:'POST',
|
||||
headers:{'X-Nd-Authorization':'Bearer '+token,'Content-Type':file.type||'image/jpeg'},
|
||||
body:file
|
||||
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})
|
||||
});
|
||||
if(!res.ok)throw new Error(res.status);
|
||||
toast('Cover aktualisiert');
|
||||
|
||||
Reference in new issue
Block a user