fix: Web Share Target akzeptiert mehr Feldnamen (Android Gallery Varianten)
All checks were successful
Deploy baustelle-pwa / deploy (push) Successful in 1s
All checks were successful
Deploy baustelle-pwa / deploy (push) Successful in 1s
Verschiedene Android-Gallery-Apps senden geteilte Bilder unter unterschiedlichen Feldnamen — photos, file, files, image, images. - Manifest listet jetzt alle drei Haupt-Feldnamen mit image/* accept - Service Worker iteriert alle bekannten Keys UND macht einen Fallback über alle FormData-Entries für unbekannte Gallery-Apps - Cache-Version v6 damit Browser Manifest neu liest Wichtig: PWA muss nach diesem Update einmal deinstalliert und neu installiert werden, damit Android das neue share_target registriert. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> [deploy]
This commit is contained in:
parent
02ffdca57c
commit
391777fdb4
2 changed files with 18 additions and 3 deletions
|
|
@ -20,8 +20,11 @@
|
||||||
"params": {
|
"params": {
|
||||||
"title": "title",
|
"title": "title",
|
||||||
"text": "text",
|
"text": "text",
|
||||||
|
"url": "url",
|
||||||
"files": [
|
"files": [
|
||||||
{ "name": "photos", "accept": ["image/jpeg", "image/png", "image/webp"] }
|
{ "name": "photos", "accept": ["image/*"] },
|
||||||
|
{ "name": "file", "accept": ["image/*"] },
|
||||||
|
{ "name": "files", "accept": ["image/*"] }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
sw.js
16
sw.js
|
|
@ -4,7 +4,7 @@
|
||||||
* - API-Calls: network-first, kein offline-cache (da auth-pflichtig)
|
* - API-Calls: network-first, kein offline-cache (da auth-pflichtig)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const CACHE = 'baustelle-v5';
|
const CACHE = 'baustelle-v6';
|
||||||
const SHELL = [
|
const SHELL = [
|
||||||
'./',
|
'./',
|
||||||
'./index.html',
|
'./index.html',
|
||||||
|
|
@ -23,7 +23,19 @@ const SHELL = [
|
||||||
// Web Share Target: eingehende POSTs an share.html abfangen und in IDB zwischenspeichern
|
// Web Share Target: eingehende POSTs an share.html abfangen und in IDB zwischenspeichern
|
||||||
async function handleShareTarget(request) {
|
async function handleShareTarget(request) {
|
||||||
const fd = await request.formData();
|
const fd = await request.formData();
|
||||||
const files = fd.getAll('photos');
|
// Alle bekannten Feldnamen durchprobieren — verschiedene Android-Gallery-Apps
|
||||||
|
// nutzen unterschiedliche Namen
|
||||||
|
let files = [];
|
||||||
|
for (const key of ['photos', 'file', 'files', 'image', 'images']) {
|
||||||
|
const v = fd.getAll(key);
|
||||||
|
if (v && v.length) files = files.concat(v);
|
||||||
|
}
|
||||||
|
// Fallback: alle File-Entries im FormData durchsuchen
|
||||||
|
if (!files.length) {
|
||||||
|
for (const [k, v] of fd.entries()) {
|
||||||
|
if (v && typeof v === 'object' && v.size !== undefined) files.push(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (files.length) {
|
if (files.length) {
|
||||||
const db = await new Promise((res, rej) => {
|
const db = await new Promise((res, rej) => {
|
||||||
const req = indexedDB.open('baustelle-pwa-v1', 1);
|
const req = indexedDB.open('baustelle-pwa-v1', 1);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue