Skip to content

Commit

Permalink
Merge pull request #175 from konecty/fix/file-upload-vips-error
Browse files Browse the repository at this point in the history
Fix: file upload vips error
  • Loading branch information
7sete7 authored Oct 7, 2024
2 parents e7cd3d0 + 3d880f1 commit 02ff1f7
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/server/routes/rest/file/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,11 @@ const fileUploadApi: FastifyPluginCallback = (fastify, _, done) => {
content: fileContent,
});

const fileSvg = `
<svg xmlns="http://www.w3.org/2000/svg">
<g>
<rect x="0" y="0" width="2048" height="2048" fill="#cccccc"></rect>
<path fill="#ffffff" transform="translate(700, 764)" d="M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z"></path>
<text x="1024" y="1400" text-anchor="middle" alignment-baseline="top" font-family="Verdana" font-size="80" fill="#ffffff">${fileName}</text>
</g>
</svg>`;
const fileSvg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 720 1024">
<g><rect x="0" y="0" width="720" height="1024" fill="#cccccc"></rect></g>
<g><path fill="#ffffff" transform="translate(40, 150)" d="M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z"></path></g>
<g><text x="256" y="900" text-anchor="middle" alignment-baseline="top" font-family="Verdana" font-size="80" fill="#ffffff">${fileName}</text></g>
</svg>`;

const fileIconBuffer = await sharp(Buffer.from(fileSvg))
.resize({
Expand Down

0 comments on commit 02ff1f7

Please sign in to comment.