Commit 3b6b111
fix(drawings): rewrite preview SVG so it doesn't inline base64 after S3 upload
Symptom: every save produced a megabyte-scale `Drawing.preview`
column. The SVG had `<image href="data:image/png;base64,...">` for
each image element instead of the S3 URL.
Root cause: the frontend generates the preview SVG from the canvas
state at save time, before the round-trip uploads files to S3. The
SVG embeds whatever dataURL the file currently has, which at save
time is still base64. processFilesForS3 only rewrites the dataURL
inside `Drawing.files`, never the parallel preview SVG, so the
inlined base64 stays in the preview forever.
Add a rewritePreviewForS3 helper in fileProcessing.ts that diffs the
original-vs-processed files map and applies the resulting URL
substitutions to the preview string. Wire it into the POST and PUT
handlers so the preview saved alongside the upload reflects the same
S3 URLs as Drawing.files.
Best-effort string substitution: it works because the same dataURL
string is character-identical in both `files[fileId].dataURL` and the
preview SVG's href. If frontend encoding ever diverges, the worst
case is the preview is left as-is — never crashes.
Change-Id: I427edabcccc1453bf0f69f5dde33c9648cfcb370
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a6410aa commit 3b6b111
2 files changed
Lines changed: 71 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
408 | 409 | | |
409 | 410 | | |
410 | 411 | | |
| 412 | + | |
411 | 413 | | |
412 | | - | |
| 414 | + | |
413 | 415 | | |
414 | 416 | | |
415 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
416 | 426 | | |
417 | 427 | | |
418 | 428 | | |
| |||
422 | 432 | | |
423 | 433 | | |
424 | 434 | | |
425 | | - | |
| 435 | + | |
426 | 436 | | |
427 | 437 | | |
428 | 438 | | |
| |||
521 | 531 | | |
522 | 532 | | |
523 | 533 | | |
| 534 | + | |
524 | 535 | | |
525 | | - | |
| 536 | + | |
526 | 537 | | |
527 | 538 | | |
528 | 539 | | |
529 | 540 | | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
530 | 554 | | |
531 | | - | |
532 | 555 | | |
533 | 556 | | |
534 | 557 | | |
| |||
0 commit comments