Skip to content
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

Issue with UTF-8 characters in filename #6664

Open
ddanninger opened this issue Mar 11, 2024 · 0 comments
Open

Issue with UTF-8 characters in filename #6664

ddanninger opened this issue Mar 11, 2024 · 0 comments

Comments

@ddanninger
Copy link

ddanninger commented Mar 11, 2024

Bug report

Describe the bug

Broken filenames, when uploading filenames with non ascii characters as media / thumbnail.

System information

Medusa version (including plugins): 1.20.2
Node.js version: v18.18.0
Database: postgres
Operating system: windows

Steps to reproduce the behavior

  1. Go to Product Detail
  2. Upload Testfile 테스트-강아지.jpg

Screenshots

screenshot-response
screenshot-body

Code snippets

Temporary fix by overwriting the route and use multer-utf8

api/middlewares.ts

import type { MiddlewaresConfig } from "@medusajs/medusa";
import multer from "multer-utf8";

const upload = multer({
  dest: "uploads/",
  charset: "utf8",
});

export const config: MiddlewaresConfig = {
  routes: [
    {
      matcher: "/admin/uploads",
      middlewares: [upload.array("files")], // OVERWRITE ADMIN UPLOAD DUE UTF8 ISSUE
    },
    {
      matcher: "/admin/uploads/protected",
      middlewares: [upload.array("files")], // OVERWRITE ADMIN UPLOAD DUE UTF8 ISSUE
    },
  ],
};

api/admin/uploads/route.ts

import createUpload from "@medusajs/medusa/dist/api/routes/admin/uploads/create-upload";

export const POST = createUpload;

api/admin/uploads/protected/route.ts

import createProtectedUpload from "@medusajs/medusa/dist/api/routes/admin/uploads/create-protected-upload";

export const POST = createProtectedUpload;

Additional Context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant