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);
|
const preview=URL.createObjectURL(file);
|
||||||
document.getElementById('edit-pl-cover').innerHTML=`<img src="${preview}" style="width:100%;height:100%;object-fit:cover">`;
|
document.getElementById('edit-pl-cover').innerHTML=`<img src="${preview}" style="width:100%;height:100%;object-fit:cover">`;
|
||||||
try{
|
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 token=await ndAuth();
|
||||||
const res=await fetch(`${cfg.url}/api/playlist/${_currentPlaylist.id}/image`,{
|
const pl=_currentPlaylist;
|
||||||
method:'POST',
|
const res=await fetch(`${cfg.url}/api/playlist/${pl.id}`,{
|
||||||
headers:{'X-Nd-Authorization':'Bearer '+token,'Content-Type':file.type||'image/jpeg'},
|
method:'PUT',
|
||||||
body:file
|
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);
|
if(!res.ok)throw new Error(res.status);
|
||||||
toast('Cover aktualisiert');
|
toast('Cover aktualisiert');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const CACHE = 'ns-v34';
|
const CACHE = 'ns-v35';
|
||||||
const PRECACHE = ['/', 'index.html', 'styles.css', 'app.js', 'manifest.json', 'icon.svg'];
|
const PRECACHE = ['/', 'index.html', 'styles.css', 'app.js', 'manifest.json', 'icon.svg'];
|
||||||
const SKIP_PATHS = ['/rest/stream', '/rest/download', '/config.js'];
|
const SKIP_PATHS = ['/rest/stream', '/rest/download', '/config.js'];
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user