ChatGPTNextWeb / ChatGPT-Next-Web

A cross-platform ChatGPT/Gemini UI (Web / PWA / Linux / Win / MacOS). 一键拥有你自己的跨平台 ChatGPT/Gemini 应用。
https://app.nextchat.dev/
MIT License
74.89k stars 58.96k forks source link

[Feature Request] using CacheStorage to store image #5013

Closed lloydzhou closed 1 month ago

lloydzhou commented 2 months ago

🥰 Feature Description

2393 #4574 #3994 #2433 #5002 #5015

using base64 string to save image content to localstorage, get error: QuotaExceededError

add new scheme: indexdb://{file_name} to read and write file in indexdb.

using CacheStorage to store image

🧐 Proposed Solution

add new scheme: indexdb://{file_name} to read and write file in indexed db

using CacheStorage to store image

  1. uploadImage using fetch
  2. hook upload api in serviceWorker: save in CacheStorage and return cache file url
  3. component using img show image content, then serviceWorker get from CacheStorage

📝 Additional Information

https://caniuse.com/?search=IndexedDB image

https://caniuse.com/?search=cachestorage image

lloydzhou commented 2 months ago

https://github.com/debingfeng/blog/blob/master/docs/javascript/practise/%E4%BD%BF%E7%94%A8IndexDB%E5%AD%98%E5%82%A8%E5%9B%BE%E5%83%8F%E5%92%8C%E6%96%87%E4%BB%B6.md

https://hacks.mozilla.org/2012/02/storing-images-and-files-in-indexeddb/

不知道有没有用的npm包 https://www.npmjs.com/search?q=indexdb%20file