mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-20 04:30:17 +09:00
add header for service worker upload api
This commit is contained in:
parent
94bc880b7f
commit
5267ad46da
@ -22,9 +22,16 @@ async function upload(request, url) {
|
|||||||
ext = file.type.split('/').pop()
|
ext = file.type.split('/').pop()
|
||||||
}
|
}
|
||||||
const fileUrl = `${url.origin}/api/cache/${nanoid()}.${ext}`
|
const fileUrl = `${url.origin}/api/cache/${nanoid()}.${ext}`
|
||||||
// console.debug('file', file, fileUrl)
|
// console.debug('file', file, fileUrl, request)
|
||||||
const cache = await caches.open(CHATGPT_NEXT_WEB_FILE_CACHE)
|
const cache = await caches.open(CHATGPT_NEXT_WEB_FILE_CACHE)
|
||||||
await cache.put(new Request(fileUrl), new Response(file))
|
await cache.put(new Request(fileUrl), new Response(file, {
|
||||||
|
headers: {
|
||||||
|
'content-type': file.type,
|
||||||
|
'content-length': file.size,
|
||||||
|
'cache-control': 'no-cache', // file already store in disk
|
||||||
|
'server': 'ServiceWorker',
|
||||||
|
}
|
||||||
|
}))
|
||||||
return Response.json({ code: 0, data: fileUrl })
|
return Response.json({ code: 0, data: fileUrl })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user