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);
|
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 pl=_currentPlaylist;
|
const form=new FormData();form.append('image',file,file.name);
|
||||||
const res=await fetch(`${cfg.url}/api/playlist/${pl.id}`,{
|
const res=await fetch(`${cfg.url}/api/playlist/${_currentPlaylist.id}/image`,{
|
||||||
method:'PUT',
|
method:'POST',
|
||||||
headers:{'X-Nd-Authorization':'Bearer '+token,'Content-Type':'application/json'},
|
headers:{'X-Nd-Authorization':'Bearer '+token},
|
||||||
body:JSON.stringify({name:pl.name,comment:pl.comment||'',public:!!pl.public,imageData})
|
body:form
|
||||||
});
|
});
|
||||||
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-v35';
|
const CACHE = 'ns-v36';
|
||||||
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