- Node.js version: 18.19.1
- NPM version: 10.2.4
- Strapi version: 4.25.4
- Database: Postgres
- Operating system: Mac/Unix
- Is your project Javascript or Typescript: Mixed
I’m starting work on a custom Strapi upload provider for box.com, whose SDK is in TypeScript. When I run my server I get the following error:
TypeError: provider.init is not a function at createProvider (/Users/erikmadsen/Documents/Projects/SBM/sbm-strapi/node_modules/@strapi/plugin-upload/server/register.js:60:37)
Provider is at providers/strapi-provider-upload-box/index.ts
Builds to dist/providers/strapi-provider-upload-box/index.js
package.json
"devDependencies": {
"ajv": "^8.17.1",
"strapi-provider-upload-box": "file:./dist/providers/strapi-provider-upload-box"
},
plugins.js
module.exports = ({env}) => ({
upload: {
config: {
provider: 'strapi-provider-upload-box',
providerOptions: {
clientId: env('BOX_CLIENT_ID'),
...
}
}
}
});
dist/providers/strapi-provider-upload-box/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// providers/upload-provider-box/index.ts
const { BoxJwtAuth, JwtConfig, BoxClient } = require('box-typescript-sdk-gen');
exports.default = {
init(providerConfig) {
return {
upload(file) {
return new Promise((resolve, reject) => {
/* My implementation */
});
},
delete(file) {
return new Promise((resolve, reject) => {
/* My implementation */
});
},
};
},
};
This topic has been created from a Discord post (1274005858904182858) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord