Fix upload URL

This commit is contained in:
2025-03-31 11:22:05 +02:00
parent 15d8238379
commit ad81718c99
3 changed files with 59 additions and 206 deletions

231
package-lock.json generated
View File

@@ -14,8 +14,8 @@
"@strapi/provider-upload-aws-s3": "^5.11.0", "@strapi/provider-upload-aws-s3": "^5.11.0",
"@strapi/strapi": "5.8.1", "@strapi/strapi": "5.8.1",
"better-sqlite3": "11.3.0", "better-sqlite3": "11.3.0",
"capture-website": "^4.2.0",
"pg": "^8.13.1", "pg": "^8.13.1",
"puppeteer": "^24.4.0",
"react": "^18.0.0", "react": "^18.0.0",
"react-dom": "^18.0.0", "react-dom": "^18.0.0",
"react-router-dom": "^6.0.0", "react-router-dom": "^6.0.0",
@@ -2904,49 +2904,6 @@
"tslib": "^2.4.0" "tslib": "^2.4.0"
} }
}, },
"node_modules/@ghostery/adblocker": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@ghostery/adblocker/-/adblocker-2.5.0.tgz",
"integrity": "sha512-CcmWiTLKxDqYiTlPyOAWr3xeZYXjWlpu6UOCDkk33k0w7jTgVrdvwbXf8Tv4XE0m3uNX6Idfj4H+Umv8L3AiUw==",
"license": "MPL-2.0",
"dependencies": {
"@ghostery/adblocker-content": "^2.5.0",
"@ghostery/adblocker-extended-selectors": "^2.5.0",
"@remusao/guess-url-type": "^1.3.0",
"@remusao/small": "^1.2.1",
"@remusao/smaz": "^1.9.1",
"tldts-experimental": "^6.0.14"
}
},
"node_modules/@ghostery/adblocker-content": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@ghostery/adblocker-content/-/adblocker-content-2.5.0.tgz",
"integrity": "sha512-Gn9fslZdacx1m1e3/2LSUPWagLObYmIDbkgvZTtgqT/OHc17VbM71AxWEjtC/xzo5K4PI25958PjvidoEH7ufw==",
"license": "MPL-2.0",
"dependencies": {
"@ghostery/adblocker-extended-selectors": "^2.5.0"
}
},
"node_modules/@ghostery/adblocker-extended-selectors": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@ghostery/adblocker-extended-selectors/-/adblocker-extended-selectors-2.5.0.tgz",
"integrity": "sha512-/GBAwErjktcBKLjCMl/n+jz2MxXFfTmEGw+hcPtAhEin49eSC09PK1TAdzDPDXkCTF4Jmb/zC+MYtbX1eZ1WsQ==",
"license": "MPL-2.0"
},
"node_modules/@ghostery/adblocker-puppeteer": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@ghostery/adblocker-puppeteer/-/adblocker-puppeteer-2.5.0.tgz",
"integrity": "sha512-5SFmit+tMMsZDmjWwstFd6G+GV3HB7+ypZ9/vSKT0vo8FI9/hHm6pLMiif+iMI626+8dHjfjA/cItL9ttAwu3w==",
"license": "MPL-2.0",
"dependencies": {
"@ghostery/adblocker": "^2.5.0",
"@ghostery/adblocker-content": "^2.5.0",
"tldts-experimental": "^6.0.14"
},
"peerDependencies": {
"puppeteer": ">5"
}
},
"node_modules/@hapi/bourne": { "node_modules/@hapi/bourne": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-3.0.0.tgz", "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-3.0.0.tgz",
@@ -3441,18 +3398,17 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@puppeteer/browsers": { "node_modules/@puppeteer/browsers": {
"version": "2.6.1", "version": "2.8.0",
"resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.6.1.tgz", "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.8.0.tgz",
"integrity": "sha512-aBSREisdsGH890S2rQqK82qmQYU3uFpSH8wcZWHgHzl3LfzsxAKbLNiAG9mO8v1Y0UICBeClICxPJvyr0rcuxg==", "integrity": "sha512-yTwt2KWRmCQAfhvbCRjebaSX8pV1//I0Y3g+A7f/eS7gf0l4eRJoUCvcYdVtboeU4CTOZQuqYbZNS8aBYb8ROQ==",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"debug": "^4.4.0", "debug": "^4.4.0",
"extract-zip": "^2.0.1", "extract-zip": "^2.0.1",
"progress": "^2.0.3", "progress": "^2.0.3",
"proxy-agent": "^6.5.0", "proxy-agent": "^6.5.0",
"semver": "^7.6.3", "semver": "^7.7.1",
"tar-fs": "^3.0.6", "tar-fs": "^3.0.8",
"unbzip2-stream": "^1.4.3",
"yargs": "^17.7.2" "yargs": "^17.7.2"
}, },
"bin": { "bin": {
@@ -4774,49 +4730,6 @@
"node": ">=14.0.0" "node": ">=14.0.0"
} }
}, },
"node_modules/@remusao/guess-url-type": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@remusao/guess-url-type/-/guess-url-type-1.3.0.tgz",
"integrity": "sha512-SNSJGxH5ckvxb3EUHj4DqlAm/bxNxNv2kx/AESZva/9VfcBokwKNS+C4D1lQdWIDM1R3d3UG+xmVzlkNG8CPTQ==",
"license": "MPL-2.0"
},
"node_modules/@remusao/small": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@remusao/small/-/small-1.3.0.tgz",
"integrity": "sha512-bydAhJI+ywmg5xMUcbqoR8KahetcfkFywEZpsyFZ8EBofilvWxbXnMSe4vnjDI1Y+SWxnNhR4AL/2BAXkf4b8A==",
"license": "MPL-2.0"
},
"node_modules/@remusao/smaz": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@remusao/smaz/-/smaz-1.10.0.tgz",
"integrity": "sha512-GQzCxmmMpLkyZwcwNgz8TpuBEWl0RUQa8IcvKiYlPxuyYKqyqPkCr0hlHI15ckn3kDUPS68VmTVgyPnLNrdVmg==",
"license": "MPL-2.0",
"dependencies": {
"@remusao/smaz-compress": "^1.10.0",
"@remusao/smaz-decompress": "^1.10.0"
}
},
"node_modules/@remusao/smaz-compress": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@remusao/smaz-compress/-/smaz-compress-1.10.0.tgz",
"integrity": "sha512-E/lC8OSU+3bQrUl64vlLyPzIxo7dxF2RvNBe9KzcM4ax43J/d+YMinmMztHyCIHqRbz7rBCtkp3c0KfeIbHmEg==",
"license": "MPL-2.0",
"dependencies": {
"@remusao/trie": "^1.5.0"
}
},
"node_modules/@remusao/smaz-decompress": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@remusao/smaz-decompress/-/smaz-decompress-1.10.0.tgz",
"integrity": "sha512-aA5ImUH480Pcs5/cOgToKmFnzi7osSNG6ft+7DdmQTaQEEst3nLq3JLlBEk+gwidURymjbx6DYs60LHaZ415VQ==",
"license": "MPL-2.0"
},
"node_modules/@remusao/trie": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@remusao/trie/-/trie-1.5.0.tgz",
"integrity": "sha512-UX+3utJKgwCsg6sUozjxd38gNMVRXrY4TNX9VvCdSrlZBS1nZjRPi98ON3QjRAdf6KCguJFyQARRsulTeqQiPg==",
"license": "MPL-2.0"
},
"node_modules/@rollup/rollup-android-arm-eabi": { "node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.32.0", "version": "4.32.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.32.0.tgz", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.32.0.tgz",
@@ -10126,24 +10039,6 @@
"tslib": "^2.0.3" "tslib": "^2.0.3"
} }
}, },
"node_modules/capture-website": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/capture-website/-/capture-website-4.2.0.tgz",
"integrity": "sha512-EmkSn36CXTC8tUsS6aNmvvsdpfVTYYkuRp7U5bV9gcJwcDbqqA5c0Op/iskYPKtDdOkuVp61mjn/LLywX0h7cw==",
"license": "MIT",
"dependencies": {
"@ghostery/adblocker-puppeteer": "^2.1.1",
"file-url": "^4.0.0",
"puppeteer": "^23.10.0",
"tough-cookie": "^5.0.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/castable-video": { "node_modules/castable-video": {
"version": "1.1.4", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/castable-video/-/castable-video-1.1.4.tgz", "resolved": "https://registry.npmjs.org/castable-video/-/castable-video-1.1.4.tgz",
@@ -10279,27 +10174,18 @@
} }
}, },
"node_modules/chromium-bidi": { "node_modules/chromium-bidi": {
"version": "0.11.0", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.11.0.tgz", "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-2.1.2.tgz",
"integrity": "sha512-6CJWHkNRoyZyjV9Rwv2lYONZf1Xm0IuDyNq97nwSsxxP3wf5Bwy15K5rOvVKMtJ127jJBmxFUanSAOjgFRxgrA==", "integrity": "sha512-vtRWBK2uImo5/W2oG6/cDkkHSm+2t6VHgnj+Rcwhb0pP74OoUb4GipyRX/T/y39gYQPhioP0DPShn+A7P6CHNw==",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"mitt": "3.0.1", "mitt": "^3.0.1",
"zod": "3.23.8" "zod": "^3.24.1"
}, },
"peerDependencies": { "peerDependencies": {
"devtools-protocol": "*" "devtools-protocol": "*"
} }
}, },
"node_modules/chromium-bidi/node_modules/zod": {
"version": "3.23.8",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
},
"node_modules/ci-info": { "node_modules/ci-info": {
"version": "3.8.0", "version": "3.8.0",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz",
@@ -11454,9 +11340,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/devtools-protocol": { "node_modules/devtools-protocol": {
"version": "0.0.1367902", "version": "0.0.1413902",
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1367902.tgz", "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1413902.tgz",
"integrity": "sha512-XxtPuC3PGakY6PD7dG66/o8KwJ/LkH2/EKe19Dcw58w53dv4/vSQEkn/SzuyhHE2q4zPgCkxQBxus3VV4ql+Pg==", "integrity": "sha512-yRtvFD8Oyk7C9Os3GmnFZLu53yAfsnyw1s+mLmHHUK0GQEc9zthHWvS1r67Zqzm5t7v56PILHIVZ7kmFMaL2yQ==",
"license": "BSD-3-Clause" "license": "BSD-3-Clause"
}, },
"node_modules/dezalgo": { "node_modules/dezalgo": {
@@ -12664,18 +12550,6 @@
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/file-url": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/file-url/-/file-url-4.0.0.tgz",
"integrity": "sha512-vRCdScQ6j3Ku6Kd7W1kZk9c++5SqD6Xz5Jotrjr/nkY714M14RFHy/AAVA2WQvpsqVAVgTbDrYyBpU205F0cLw==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/fill-range": { "node_modules/fill-range": {
"version": "7.1.1", "version": "7.1.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
@@ -18687,17 +18561,17 @@
} }
}, },
"node_modules/puppeteer": { "node_modules/puppeteer": {
"version": "23.11.1", "version": "24.4.0",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.11.1.tgz", "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.4.0.tgz",
"integrity": "sha512-53uIX3KR5en8l7Vd8n5DUv90Ae9QDQsyIthaUFVzwV6yU750RjqRznEtNMBT20VthqAdemnJN+hxVdmMHKt7Zw==", "integrity": "sha512-E4JhJzjS8AAI+6N/b+Utwarhz6zWl3+MR725fal+s3UlOlX2eWdsvYYU+Q5bXMjs9eZEGkNQroLkn7j11s2k1Q==",
"hasInstallScript": true, "hasInstallScript": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@puppeteer/browsers": "2.6.1", "@puppeteer/browsers": "2.8.0",
"chromium-bidi": "0.11.0", "chromium-bidi": "2.1.2",
"cosmiconfig": "^9.0.0", "cosmiconfig": "^9.0.0",
"devtools-protocol": "0.0.1367902", "devtools-protocol": "0.0.1413902",
"puppeteer-core": "23.11.1", "puppeteer-core": "24.4.0",
"typed-query-selector": "^2.12.0" "typed-query-selector": "^2.12.0"
}, },
"bin": { "bin": {
@@ -18708,17 +18582,17 @@
} }
}, },
"node_modules/puppeteer-core": { "node_modules/puppeteer-core": {
"version": "23.11.1", "version": "24.4.0",
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.11.1.tgz", "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.4.0.tgz",
"integrity": "sha512-3HZ2/7hdDKZvZQ7dhhITOUg4/wOrDRjyK2ZBllRB0ZCOi9u0cwq1ACHDjBB+nX+7+kltHjQvBRdeY7+W0T+7Gg==", "integrity": "sha512-eFw66gCnWo0X8Hyf9KxxJtms7a61NJVMiSaWfItsFPzFBsjsWdmcNlBdsA1WVwln6neoHhsG+uTVesKmTREn/g==",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@puppeteer/browsers": "2.6.1", "@puppeteer/browsers": "2.8.0",
"chromium-bidi": "0.11.0", "chromium-bidi": "2.1.2",
"debug": "^4.4.0", "debug": "^4.4.0",
"devtools-protocol": "0.0.1367902", "devtools-protocol": "0.0.1413902",
"typed-query-selector": "^2.12.0", "typed-query-selector": "^2.12.0",
"ws": "^8.18.0" "ws": "^8.18.1"
}, },
"engines": { "engines": {
"node": ">=18" "node": ">=18"
@@ -21330,33 +21204,6 @@
"upper-case": "^1.0.3" "upper-case": "^1.0.3"
} }
}, },
"node_modules/tldts": {
"version": "6.1.85",
"resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.85.tgz",
"integrity": "sha512-gBdZ1RjCSevRPFix/hpaUWeak2/RNUZB4/8frF1r5uYMHjFptkiT0JXIebWvgI/0ZHXvxaUDDJshiA0j6GdL3w==",
"license": "MIT",
"dependencies": {
"tldts-core": "^6.1.85"
},
"bin": {
"tldts": "bin/cli.js"
}
},
"node_modules/tldts-core": {
"version": "6.1.85",
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.85.tgz",
"integrity": "sha512-DTjUVvxckL1fIoPSb3KE7ISNtkWSawZdpfxGxwiIrZoO6EbHVDXXUIlIuWympPaeS+BLGyggozX/HTMsRAdsoA==",
"license": "MIT"
},
"node_modules/tldts-experimental": {
"version": "6.1.85",
"resolved": "https://registry.npmjs.org/tldts-experimental/-/tldts-experimental-6.1.85.tgz",
"integrity": "sha512-oM+m5GnOdxgbnfSfix98YvzAIgkKZbdqMD/BTLbnbL349MyaEeNo6z8jVX9/lrL6DvnjgW7RV+sIVojrFvB+hw==",
"license": "MIT",
"dependencies": {
"tldts-core": "^6.1.85"
}
},
"node_modules/tmp": { "node_modules/tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
@@ -21414,18 +21261,6 @@
"nodetouch": "bin/nodetouch.js" "nodetouch": "bin/nodetouch.js"
} }
}, },
"node_modules/tough-cookie": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz",
"integrity": "sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==",
"license": "BSD-3-Clause",
"dependencies": {
"tldts": "^6.1.32"
},
"engines": {
"node": ">=16"
}
},
"node_modules/tree-kill": { "node_modules/tree-kill": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
@@ -21614,16 +21449,6 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/unbzip2-stream": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz",
"integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==",
"license": "MIT",
"dependencies": {
"buffer": "^5.2.1",
"through": "^2.3.8"
}
},
"node_modules/unc-path-regex": { "node_modules/unc-path-regex": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz",

View File

@@ -6,7 +6,7 @@
"scripts": { "scripts": {
"build": "strapi build", "build": "strapi build",
"deploy": "strapi deploy", "deploy": "strapi deploy",
"develop": "strapi develop", "develop": "strapi develop --debug",
"start": "strapi start", "start": "strapi start",
"strapi": "strapi" "strapi": "strapi"
}, },
@@ -17,8 +17,8 @@
"@strapi/provider-upload-aws-s3": "^5.11.0", "@strapi/provider-upload-aws-s3": "^5.11.0",
"@strapi/strapi": "5.8.1", "@strapi/strapi": "5.8.1",
"better-sqlite3": "11.3.0", "better-sqlite3": "11.3.0",
"capture-website": "^4.2.0",
"pg": "^8.13.1", "pg": "^8.13.1",
"puppeteer": "^24.4.0",
"react": "^18.0.0", "react": "^18.0.0",
"react-dom": "^18.0.0", "react-dom": "^18.0.0",
"react-router-dom": "^6.0.0", "react-router-dom": "^6.0.0",

View File

@@ -2,6 +2,7 @@
* board-card controller * board-card controller
*/ */
import { factories } from "@strapi/strapi"; import { factories } from "@strapi/strapi";
import puppeteer from "puppeteer";
export default factories.createCoreController( export default factories.createCoreController(
"api::board-card.board-card", "api::board-card.board-card",
@@ -18,8 +19,35 @@ export default factories.createCoreController(
ctx.request.body.data = JSON.parse(ctx.request.body.data); ctx.request.body.data = JSON.parse(ctx.request.body.data);
switch (ctx.request.body.data.type) { switch (ctx.request.body.data.type) {
case "link": case "link":
break; const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(ctx.request.body.data.url);
const buffer = await page.screenshot();
const blob = new Blob([buffer], {
type: "image/png",
});
const file = new File([blob], ctx.request.body.data.title + ".png");
await browser.close();
const payload2 = {
fileInfo: {
caption: "undefined",
alternativeText: ctx.request.body.data.title || "",
name: `${ctx.request.body.data.title}.png`,
},
};
const uploadResponse =
await strapi.plugins.upload.services.upload.upload({
data: payload2,
files: {
filepath: buffer,
originalFilename: "uploadurl.png",
mimetype: "image/png",
},
});
ctx.request.body.data.image = uploadResponse[0].id;
break;
case "link2":
case "image": case "image":
case "video": case "video":
case "audio": case "audio":