-
Notifications
You must be signed in to change notification settings - Fork 0
feat: create strapi-provider-media-upload plugin #1177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Vercel provider"?
|
|
||
| ## Author | ||
|
|
||
| Created by [Frameless](https://github.com/frameless). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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