1 {"slug":"/references/file-provider-module","title":"How to Create a File Module Provider","frontmatter":{"slug":"/references/file-provider-module","keywords":["file","storage","provider","integration"]},"toc":[{"title":"Implementation Example","id":"implementation-example","level":2},{"title":"Create Module Provider Directory","id":"create-module-provider-directory","level":2},{"title":"2. Create the File Module Provider's Service","id":"2-create-the-file-module-provider-s-service","level":2},{"title":"constructor","id":"constructor","level":3},{"title":"Example","id":"example","level":4},{"title":"identifier","id":"identifier","level":3},{"title":"Example","id":"example-1","level":4},{"title":"delete","id":"delete","level":3},{"title":"Example","id":"example-2","level":4},{"title":"Parameters","id":"delete-parameters","level":4},{"title":"Returns","id":"delete-returns","level":4},{"title":"getAsBuffer","id":"getasbuffer","level":3},{"title":"Example","id":"example-3","level":4},{"title":"Parameters","id":"getasbuffer-parameters","level":4},{"title":"Returns","id":"getasbuffer-returns","level":4},{"title":"getDownloadStream","id":"getdownloadstream","level":3},{"title":"Example","id":"example-4","level":4},{"title":"Parameters","id":"getdownloadstream-parameters","level":4},{"title":"Returns","id":"getdownloadstream-returns","level":4},{"title":"getPresignedDownloadUrl","id":"getpresigneddownloadurl","level":3},{"title":"Example","id":"example-5","level":4},{"title":"Parameters","id":"getpresigneddownloadurl-parameters","level":4},{"title":"Returns","id":"getpresigneddownloadurl-returns","level":4},{"title":"getPresignedUploadUrl","id":"getpresigneduploadurl","level":3},{"title":"Example","id":"example-6","level":4},{"title":"Parameters","id":"getpresigneduploadurl-parameters","level":4},{"title":"Returns","id":"getpresigneduploadurl-returns","level":4},{"title":"getUploadStream","id":"getuploadstream","level":3},{"title":"Example","id":"example-7","level":4},{"title":"Parameters","id":"getuploadstream-parameters","level":4},{"title":"Returns","id":"getuploadstream-returns","level":4},{"title":"upload","id":"upload","level":3},{"title":"Example","id":"example-8","level":4},{"title":"Parameters","id":"upload-parameters","level":4},{"title":"Returns","id":"upload-returns","level":4},{"title":"validateOptions","id":"validateoptions","level":3},{"title":"Example","id":"example-9","level":4},{"title":"Parameters","id":"validateoptions-parameters","level":4},{"title":"3. Create Module Provider Definition File","id":"3-create-module-provider-definition-file","level":2},{"title":"4. Use Module Provider","id":"4-use-module-provider","level":2},{"title":"5. Test it Out","id":"5-test-it-out","level":2}],"blocks":[{"kind":"markdown","html":"In this document, you’ll learn how to create a File Module Provider and the methods you must implement in its main service."},{"kind":"markdown","html":"---"},{"kind":"heading","level":2,"text":"Implementation Example","id":"implementation-example"},{"kind":"markdown","html":"As you implement your File Module Provider, it can be useful to refer to an existing provider and how it's implemeted.\n\nIf you need to refer to an existing implementation as an example, check the [S3 File Module Provider in the Medusa repository](https://github.com/medusajs/medusa/tree/develop/packages/modules/providers/file-s3).\n\n---"},{"kind":"heading","level":2,"text":"Create Module Provider Directory","id":"create-module-provider-directory"},{"kind":"markdown","html":"Start by creating a new directory for your module provider.\n\nIf you're creating the module provider in a Medusa application, create it under the `src/modules` directory. For example, `src/modules/my-file`.\n\nIf you're creating the module provider in a plugin, create it under the `src/providers` directory. For example, `src/providers/my-file`."},{"kind":"note","variant":"note","html":"The rest of this guide always uses the `src/modules/my-file` directory as an example."},{"kind":"markdown","html":"---"},{"kind":"heading","level":2,"text":"2. Create the File Module Provider's Service","id":"2-create-the-file-module-provider-s-service"},{"kind":"markdown","html":"Create the file `src/modules/my-file/service.ts` that holds the implementation of the module provider's main service. It must extend the `AbstractFileProviderService` class imported from `@medusajs/framework/utils`:\n\n```ts title=\"src/modules/my-file/service.ts\"\nimport { AbstractFileProviderService } from \"@medusajs/framework/utils\"\n\nclass MyFileProviderService extends AbstractFileProviderService {\n // TODO implement methods\n}\n\nexport default MyFileProviderService\n```"},{"kind":"heading","level":3,"text":"constructor","id":"constructor"},{"kind":"markdown","html":"The constructor allows you to access resources from the module's container using the first parameter,\nand the module's options using the second parameter.\n\nIf you're creating a client or establishing a connection with a third-party service, do it in the constructor."},{"kind":"heading","level":4,"text":"Example","id":"example"},{"kind":"markdown","html":"```ts\nimport { Logger } from \"@medusajs/framework/types\"\nimport { AbstractFileProviderService } from \"@medusajs/framework/utils\"\n\ntype InjectedDependencies = {\n logger: Logger\n}\n\ntype Options = {\n apiKey: string\n}\n\nclass MyFileProviderService extends AbstractFileProviderService {\n protected logger_: Logger\n protected options_: Options\n static identifier = \"my-file\"\n // assuming you're initializing a client\n protected client\n\n constructor (\n { logger }: InjectedDependencies,\n options: Options\n ) {\n super()\n\n this.logger_ = logger\n this.options_ = options\n\n // assuming you're initializing a client\n this.client = new Client(options)\n }\n}\n\nexport default MyFileProviderService\n```"},{"kind":"heading","level":3,"text":"identifier","id":"identifier"},{"kind":"markdown","html":"Each file provider has a unique ID used to identify it. The provider's ID\nwill be stored as `fs_{identifier}_{id}`, where `{id}` is the provider's `id`\nproperty in the `medusa-config.ts`."},{"kind":"heading","level":4,"text":"Example","id":"example-1"},{"kind":"markdown","html":"```ts\nclass MyFileProviderService extends AbstractFileProviderService {\n static identifier = \"my-file\"\n // ...\n}\n```"},{"kind":"heading","level":3,"text":"delete","id":"delete"},{"kind":"markdown","html":"This method deletes one or more files from the storage. It's used when an admin user\ndeletes a product image, or other custom file deletions."},{"kind":"heading","level":4,"text":"Example","id":"example-2"},{"kind":"markdown","html":"```ts\nclass MyFileProviderService extends AbstractFileProviderService {\n // ...\n async delete(\n files: FileTypes.ProviderDeleteFileDTO | FileTypes.ProviderDeleteFileDTO[]\n ): Promise<void> {\n // TODO logic to remove the file from storage\n // Use the `file.fileKey` to delete the file, which is the identifier of the file\n // in the provider's storage.\n // for example:\n const fileArray = Array.isArray(files) ? files : [files]\n for (const file of fileArray) {\n this.client.delete(file.fileKey)\n }\n }\n}\n```"},{"kind":"heading","level":4,"text":"Parameters","id":"delete-parameters"},{"kind":"typeList","sectionTitle":"delete","types":[{"name":"files","type":"[ProviderDeleteFileDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderDeleteFileDTO) \\| [ProviderDeleteFileDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderDeleteFileDTO)[]","description":"The details of the files to delete.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fileKey","type":"`string`","description":"The file's key. When uploading a file, the\nreturned key is used here.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":4,"text":"Returns","id":"delete-returns"},{"kind":"typeList","sectionTitle":"delete","types":[{"name":"Promise","type":"Promise&#60;void&#62;","optional":false,"defaultValue":"","description":"Resolves when the files are deleted.","expandable":false,"children":[]}]},{"kind":"heading","level":3,"text":"getAsBuffer","id":"getasbuffer"},{"kind":"markdown","html":"This method retrieves an uploaded file as a buffer. This is useful when you want to\nprocess the entire file in memory or send it as a response."},{"kind":"note","variant":"note","html":"This is available starting from [Medusa v2.8.0](https://github.com/medusajs/medusa/releases/tag/v2.8.0)."},{"kind":"heading","level":4,"text":"Example","id":"example-3"},{"kind":"markdown","html":"```ts\nclass MyFileProviderService extends AbstractFileProviderService {\n // ...\n async getAsBuffer(file: ProviderDeleteFileDTO): Promise<Buffer> {\n // TODO logic to get the file as a buffer\n // Use the `file.fileKey` to get the file, which is the identifier of the file\n // in the provider's storage.\n // for example:\n this.client.getAsBuffer(file.fileKey)\n }\n}\n```"},{"kind":"heading","level":4,"text":"Parameters","id":"getasbuffer-parameters"},{"kind":"typeList","sectionTitle":"getAsBuffer","types":[{"name":"fileData","type":"[ProviderGetFileDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderGetFileDTO)","description":"The details of the file to get its buffer.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fileKey","type":"`string`","description":"The file's key allowing you to later\nidentify the file in the third-party\nsystem. For example, the S3 Module Provider\nreturns the file's key in S3, whereas the\nLocal File Module Provider returns the file's\npath.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":4,"text":"Returns","id":"getasbuffer-returns"},{"kind":"typeList","sectionTitle":"getAsBuffer","types":[{"name":"Promise","type":"Promise&#60;Buffer&#60;ArrayBufferLike&#62;&#62;","optional":false,"defaultValue":"","description":"The file's buffer.","expandable":false,"children":[],"since":"2.8.0"}]},{"kind":"heading","level":3,"text":"getDownloadStream","id":"getdownloadstream"},{"kind":"markdown","html":"This method retrieves an uploaded file as a stream. This is useful when streaming\na file to clients or you want to process the file in chunks."},{"kind":"note","variant":"note","html":"This is available starting from [Medusa v2.8.0](https://github.com/medusajs/medusa/releases/tag/v2.8.0)."},{"kind":"heading","level":4,"text":"Example","id":"example-4"},{"kind":"markdown","html":"```ts\nclass MyFileProviderService extends AbstractFileProviderService {\n // ...\n async getAsStream(file: ProviderDeleteFileDTO): Promise<Readable> {\n // TODO logic to get the file as a stream\n // Use the `file.fileKey` to get the file, which is the identifier of the file\n // in the provider's storage.\n // for example:\n this.client.getAsStream(file.fileKey)\n }\n}\n```"},{"kind":"heading","level":4,"text":"Parameters","id":"getdownloadstream-parameters"},{"kind":"typeList","sectionTitle":"getDownloadStream","types":[{"name":"fileData","type":"[ProviderGetFileDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderGetFileDTO)","description":"The details of the file to get its stream.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fileKey","type":"`string`","description":"The file's key allowing you to later\nidentify the file in the third-party\nsystem. For example, the S3 Module Provider\nreturns the file's key in S3, whereas the\nLocal File Module Provider returns the file's\npath.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":4,"text":"Returns","id":"getdownloadstream-returns"},{"kind":"typeList","sectionTitle":"getDownloadStream","types":[{"name":"Promise","type":"Promise&#60;Readable&#62;","optional":false,"defaultValue":"","description":"The file's stream.","expandable":false,"children":[],"since":"2.8.0"}]},{"kind":"heading","level":3,"text":"getPresignedDownloadUrl","id":"getpresigneddownloadurl"},{"kind":"markdown","html":"This method is used to retrieve a download URL of the file. For some providers,\nsuch as S3, a presigned URL indicates a temporary URL to get access to a file.\n\nIf your provider doesn’t perform or offer a similar functionality, you can\nreturn the URL to download the file."},{"kind":"heading","level":4,"text":"Example","id":"example-5"},{"kind":"markdown","html":"```ts\nclass MyFileProviderService extends AbstractFileProviderService {\n // ...\n async getPresignedDownloadUrl(\n fileData: ProviderGetFileDTO\n ): Promise<string> {\n // TODO logic to get the presigned URL\n // Use the `file.fileKey` to delete the file, which is the identifier of the file\n // in the provider's storage.\n // for example:\n return this.client.getPresignedUrl(fileData.fileKey)\n }\n}\n```"},{"kind":"heading","level":4,"text":"Parameters","id":"getpresigneddownloadurl-parameters"},{"kind":"typeList","sectionTitle":"getPresignedDownloadUrl","types":[{"name":"fileData","type":"[ProviderGetFileDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderGetFileDTO)","description":"The details of the file to get its\npresigned URL.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fileKey","type":"`string`","description":"The file's key allowing you to later\nidentify the file in the third-party\nsystem. For example, the S3 Module Provider\nreturns the file's key in S3, whereas the\nLocal File Module Provider returns the file's\npath.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":4,"text":"Returns","id":"getpresigneddownloadurl-returns"},{"kind":"typeList","sectionTitle":"getPresignedDownloadUrl","types":[{"name":"Promise","type":"Promise&#60;string&#62;","optional":false,"defaultValue":"","description":"The file's presigned URL.","expandable":false,"children":[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":3,"text":"getPresignedUploadUrl","id":"getpresigneduploadurl"},{"kind":"badges","badges":[{"variant":"neutral","label":"optional"}]},{"kind":"markdown","html":"This method is used to get a presigned upload URL for a file. For some providers,\nsuch as S3, a presigned URL indicates a temporary URL to get upload a file.\n\nIf your provider doesn’t perform or offer a similar functionality, you don't have to\nimplement this method. Instead, an error is thrown when the method is called."},{"kind":"heading","level":4,"text":"Example","id":"example-6"},{"kind":"markdown","html":"```ts\nclass MyFileProviderService extends AbstractFileProviderService {\n // ...\n async getPresignedUploadUrl(\n fileData: ProviderGetPresignedUploadUrlDTO\n ): Promise<ProviderFileResultDTO> {\n // TODO logic to get the presigned upload URL\n // for example:\n return this.client.getPresignedUploadUrl(fileData.filename, fileData.mimeType)\n }\n}\n```"},{"kind":"heading","level":4,"text":"Parameters","id":"getpresigneduploadurl-parameters"},{"kind":"typeList","sectionTitle":"getPresignedUploadUrl","types":[{"name":"fileData","type":"[ProviderGetPresignedUploadUrlDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderGetPresignedUploadUrlDTO)","description":"The details of the file to get a presigned upload URL for.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"filename","type":"`string`","description":"The filename of the file to get a presigned upload URL for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mimeType","type":"`string`","description":"The mimetype of the file to get a presigned upload URL for.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"access","type":"[FileAccessPermission](/references/types/FileTypes/types/types.FileTypes.FileAccessPermission)","description":"The access level of the file to get a presigned upload URL for.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expiresIn","type":"`number`","description":"The validity of the presigned upload URL in seconds.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":4,"text":"Returns","id":"getpresigneduploadurl-returns"},{"kind":"typeList","sectionTitle":"getPresignedUploadUrl","types":[{"name":"Promise","type":"Promise&#60;[ProviderFileResultDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderFileResultDTO)&#62;","optional":false,"defaultValue":"","description":"The presigned URL and file key to upload the file to","expandable":false,"children":[{"name":"url","type":"`string`","description":"The file's URL that users or systems\ncan use to access the file.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"key","type":"`string`","description":"The file's key allowing you to later\nidentify the file in the third-party\nsystem. For example, the S3 Module Provider\nreturns the file's key in S3, whereas the\nLocal File Module Provider returns the file's\npath.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":3,"text":"getUploadStream","id":"getuploadstream"},{"kind":"markdown","html":"This method returns a writeable stream to upload a file."},{"kind":"note","variant":"note","html":"This is available starting from [Medusa v2.8.0](https://github.com/medusajs/medusa/releases/tag/v2.8.0)."},{"kind":"heading","level":4,"text":"Example","id":"example-7"},{"kind":"markdown","html":"```ts\nclass MyFileProviderService extends AbstractFileProviderService {\n // ...\n async getUploadStream(fileData: FileTypes.ProviderUploadStreamDTO): Promise<{\n writeStream: Writable\n promise: Promise<FileTypes.ProviderFileResultDTO>\n url: string\n fileKey: string\n }> {\n // TODO logic to get the writeable stream\n }\n}\n```"},{"kind":"heading","level":4,"text":"Parameters","id":"getuploadstream-parameters"},{"kind":"typeList","sectionTitle":"getUploadStream","types":[{"name":"fileData","type":"[ProviderUploadStreamDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderUploadStreamDTO)","description":"The details of the file to upload.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"filename","type":"`string`","description":"The filename of the uploaded file","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mimeType","type":"`string`","description":"The mimetype of the uploaded file","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"access","type":"[FileAccessPermission](/references/types/FileTypes/types/types.FileTypes.FileAccessPermission)","description":"The access level of the file. Defaults to private if not passed","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":4,"text":"Returns","id":"getuploadstream-returns"},{"kind":"typeList","sectionTitle":"getUploadStream","types":[{"name":"Promise","type":"Promise&#60;object&#62;","optional":false,"defaultValue":"","description":"The writeable stream and upload promise.","expandable":false,"children":[{"name":"writeStream","type":"`Writable`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promise","type":"Promise&#60;[ProviderFileResultDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderFileResultDTO)&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"url","type":"`string`","description":"The file's URL that users or systems\ncan use to access the file.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"key","type":"`string`","description":"The file's key allowing you to later\nidentify the file in the third-party\nsystem. For example, the S3 Module Provider\nreturns the file's key in S3, whereas the\nLocal File Module Provider returns the file's\npath.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"url","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fileKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}],"since":"2.8.0"}]},{"kind":"heading","level":3,"text":"upload","id":"upload"},{"kind":"markdown","html":"This method uploads a file using your provider's custom logic. In this method, you can upload the file\ninto your provider's storage, and return the uploaded file's details.\n\nThis method will be used when uploading product images, CSV files for imports, or other\ncustom file uploads."},{"kind":"heading","level":4,"text":"Example","id":"example-8"},{"kind":"markdown","html":"```ts\nclass MyFileProviderService extends AbstractFileProviderService {\n // ...\n async upload(\n file: ProviderUploadFileDTO\n ): Promise<ProviderFileResultDTO> {\n // TODO upload file to third-party provider\n // or using custom logic\n // for example:\n this.client.upload(file)\n\n return {\n url: \"some-url.com\",\n key: \"file-name-or-id\"\n }\n }\n}\n```"},{"kind":"heading","level":4,"text":"Parameters","id":"upload-parameters"},{"kind":"typeList","sectionTitle":"upload","types":[{"name":"file","type":"[ProviderUploadFileDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderUploadFileDTO)","description":"The file to upload.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"filename","type":"`string`","description":"The filename of the uploaded file","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mimeType","type":"`string`","description":"The mimetype of the uploaded file","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"content","type":"`string`","description":"The file content as a base64-encoded string","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"access","type":"[FileAccessPermission](/references/types/FileTypes/types/types.FileTypes.FileAccessPermission)","description":"The access level of the file. Defaults to private if not passed","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":4,"text":"Returns","id":"upload-returns"},{"kind":"typeList","sectionTitle":"upload","types":[{"name":"Promise","type":"Promise&#60;[ProviderFileResultDTO](/references/types/FileTypes/interfaces/types.FileTypes.ProviderFileResultDTO)&#62;","optional":false,"defaultValue":"","description":"The uploaded file's details.","expandable":false,"children":[{"name":"url","type":"`string`","description":"The file's URL that users or systems\ncan use to access the file.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"key","type":"`string`","description":"The file's key allowing you to later\nidentify the file in the third-party\nsystem. For example, the S3 Module Provider\nreturns the file's key in S3, whereas the\nLocal File Module Provider returns the file's\npath.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":3,"text":"validateOptions","id":"validateoptions"},{"kind":"markdown","html":"This method validates the options of the provider set in `medusa-config.ts`.\nImplementing this method is optional. It's useful if your provider requires custom validation.\n\nIf the options aren't valid, throw an error."},{"kind":"heading","level":4,"text":"Example","id":"example-9"},{"kind":"markdown","html":"```ts\nclass MyFileProviderService extends AbstractFileProviderService {\n static validateOptions(options: Record<any, any>) {\n if (!options.apiKey) {\n throw new MedusaError(\n MedusaError.Types.INVALID_DATA,\n \"API key is required in the provider's options.\"\n )\n }\n }\n}\n```"},{"kind":"heading","level":4,"text":"Parameters","id":"validateoptions-parameters"},{"kind":"typeList","sectionTitle":"validateOptions","types":[{"name":"options","type":"`Record<any, any>`","description":"The provider's options.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"kind":"markdown","html":"---"},{"kind":"heading","level":2,"text":"3. Create Module Provider Definition File","id":"3-create-module-provider-definition-file"},{"kind":"markdown","html":"Create the file `src/modules/my-file/index.ts` with the following content:\n\n```ts title=\"src/modules/my-file/index.ts\"\nimport MyFileProviderService from \"./service\"\nimport { \n ModuleProvider, \n Modules\n} from \"@medusajs/framework/utils\"\n\nexport default ModuleProvider(Modules.FILE, {\n services: [MyFileProviderService],\n})\n```\n\nThis exports the module provider's definition, indicating that the `MyFileProviderService` is the module provider's service.\n\n---"},{"kind":"heading","level":2,"text":"4. Use Module Provider","id":"4-use-module-provider"},{"kind":"markdown","html":"To use your File Module Provider, add it to the `providers` array of the File Module in `medusa-config.ts`:"},{"kind":"note","variant":"note","html":"The File Module accepts one provider only."},{"kind":"markdown","html":"```ts title=\"medusa-config.ts\"\nmodule.exports = defineConfig({\n // ...\n modules: [\n {\n resolve: \"@medusajs/medusa/file\",\n options: {\n providers: [\n // default provider\n {\n resolve: \"@medusajs/medusa/file-local\",\n id: \"local\",\n },\n {\n // if module provider is in a plugin, use `plugin-name/providers/my-file`\n resolve: \"./src/modules/my-file\",\n id: \"my-file\",\n options: {\n // provider options...\n },\n },\n ],\n },\n },\n ]\n})\n```\n\n\n---"},{"kind":"heading","level":2,"text":"5. Test it Out","id":"5-test-it-out"},{"kind":"markdown","html":"To test out your File Module Provider, use the Medusa Admin or the [Upload API route](https://docs.medusajs.com/api/admin/uploads/upload-files) to upload a file."}]}