From 7787fe96aabe8b1d786aa3b1e334ff0fd56bcf59 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 18 May 2023 18:24:27 +0300 Subject: [PATCH] docs: added optional step for local file service (#4126) --- .../file-service/create-file-service.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/content/development/file-service/create-file-service.md b/docs/content/development/file-service/create-file-service.md index 88d8735426..44e8f71fa7 100644 --- a/docs/content/development/file-service/create-file-service.md +++ b/docs/content/development/file-service/create-file-service.md @@ -402,6 +402,30 @@ npx @medusajs/medusa-cli develop Then, try uploading a file, for example, using the [Upload File endpoint](/api/admin#tag/Uploads/operation/PostUploads). The file should be uploaded based on the logic you’ve implemented. +### (Optional) Accessing the File + +:::note + +This step is only useful if you're implementing a local file service. + +::: + +Since the file is uploaded to a local directory `uploads`, you need to configure a static route in express that allows accessing the files within the `uploads` directory. + +To do that, create the file `src/api/index.ts` with the following content: + +```ts +import express from "express" + +export default () => { + const app = express.Router() + + app.use(`/uploads`, express.static(uploadDir)) + + return app +} +``` + --- ## See Also