mirror of
https://github.com/Dvorinka/excalidraw-full.git
synced 2026-06-03 22:02:57 +00:00
Add thumbnail support to Canvas and storage backends
Introduces a 'thumbnail' field to the Canvas model and updates all storage backends (AWS S3, filesystem, memory, and SQLite) to handle storing and retrieving this field. Also updates the API handler to accept and save the thumbnail, and switches SQLite driver to modernc.org/sqlite for improved compatibility. Updates .gitignore to exclude .db files.
This commit is contained in:
+13
-6
@@ -113,20 +113,27 @@ func HandleSaveCanvas(store stores.Store) http.HandlerFunc {
|
||||
AppState struct {
|
||||
Name string `json:"name"`
|
||||
} `json:"appState"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
}
|
||||
// We make a copy of the body because json.Unmarshal will consume the reader.
|
||||
bodyCopy := make([]byte, len(body))
|
||||
copy(bodyCopy, body)
|
||||
|
||||
canvasName := key // Default to key
|
||||
if err := json.Unmarshal(bodyCopy, &canvasData); err == nil && canvasData.AppState.Name != "" {
|
||||
canvasName = canvasData.AppState.Name
|
||||
var canvasThumbnail string
|
||||
if err := json.Unmarshal(bodyCopy, &canvasData); err == nil {
|
||||
if canvasData.AppState.Name != "" {
|
||||
canvasName = canvasData.AppState.Name
|
||||
}
|
||||
canvasThumbnail = canvasData.Thumbnail
|
||||
}
|
||||
|
||||
canvas := &core.Canvas{
|
||||
ID: key,
|
||||
UserID: claims.Subject,
|
||||
Name: canvasName,
|
||||
Data: body,
|
||||
ID: key,
|
||||
UserID: claims.Subject,
|
||||
Name: canvasName,
|
||||
Thumbnail: canvasThumbnail,
|
||||
Data: body,
|
||||
}
|
||||
|
||||
if err := store.Save(r.Context(), canvas); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user