feat: create strapi-provider-media-upload plugin#1177
feat: create strapi-provider-media-upload plugin#1177AliKdhim87 wants to merge 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Deze config is wel erg uitgebreid, zouden alle strapi plugins niet een gedeelde tsconfig kunnen extenden?
|
|
||
| 3. Open the `plugins.ts` file for editing. | ||
|
|
||
| 4. Add the following configuration to set up the Vercel provider: |
|
|
||
| ## Author | ||
|
|
||
| Created by [Frameless](https://github.com/frameless). |
There was a problem hiding this comment.
| Created by [Frameless](https://github.com/frameless). | |
| Created by [Frameless](https://frameless.io/). |
|
|
||
| // Mime type check | ||
| if (allowedMimeTypes && !allowedMimeTypes.includes(file.mime)) { | ||
| const allowedTypes = allowedMimeTypes.map((type) => type.split('/')[1].toUpperCase()).join(', '); |
There was a problem hiding this comment.
Dit is geen nauwkeurige benadering, ik zou gewoon een lijst maken van alle volledige mime types.
| } | ||
|
|
||
| // Mime type check | ||
| if (allowedMimeTypes && !allowedMimeTypes.includes(file.mime)) { |
There was a problem hiding this comment.
om een goede match te hebben, onafhankelijk van hoofdletters enzo, stel ik voor dat je een library gebruikt om de mime type te normaliseren. Zowel de lijst met mime types die uit de configuratie komt, als de file.mime. Ik zou zo vroeg mogelijk in het proces die normalisatie doen. https://www.npmjs.com/package/media-type is een library van een goede developer die ik vertrouw.
| throw new Error('Strapi global object with dirs.static.public is not available.'); | ||
| } | ||
|
|
||
| const uploadPath = path.resolve(strapiGlobal.dirs.static.public, UPLOADS_FOLDER_NAME); |
There was a problem hiding this comment.
Waarom maken we niet de hele path configurable? Waarom is uploads hardcoded?
| }, | ||
|
|
||
| delete(file: File): Promise<string | void> { | ||
| return new Promise((resolve, reject) => { |
There was a problem hiding this comment.
Waarom doen we hier promises op de "oude manier", in plaats van await?
| if (!fs.existsSync(filePath)) { | ||
| resolve("File doesn't exist"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Volgens mij word existSync afgeraden, zou een try/catch om unlink beter en voldoende zijn?
Screen.Recording.2025-06-04.at.09.45.16.mov