fix(medusa,file-local,file-s3,core-flows): fix csv parsing special characters (#13649)

* fix(): fix csv parsing special characters

* remove other tries

* tweak

* remove comments

* Create rude-mirrors-hang.md
This commit is contained in:
William Bouchard
2025-10-02 08:24:18 -04:00
committed by GitHub
parent 5c77b10fa6
commit bb08edd41f
5 changed files with 38 additions and 5 deletions

View File

@@ -57,7 +57,19 @@ export class LocalFileService extends AbstractFileProviderService {
const filePath = this.getUploadFilePath(baseDir, fileKey)
const fileUrl = this.getUploadFileUrl(fileKey)
const content = Buffer.from(file.content as string, "binary")
let content: Buffer
try {
const decoded = Buffer.from(file.content, "base64")
if (decoded.toString("base64") === file.content) {
content = decoded
} else {
content = Buffer.from(file.content, "utf8")
}
} catch {
// Last-resort fallback: binary
content = Buffer.from(file.content, "binary")
}
await fs.writeFile(filePath, content)
return {

View File

@@ -120,7 +120,19 @@ export class S3FileService extends AbstractFileProviderService {
parsedFilename.ext
}`
const content = Buffer.from(file.content, "binary")
let content: Buffer
try {
const decoded = Buffer.from(file.content, "base64")
if (decoded.toString("base64") === file.content) {
content = decoded
} else {
content = Buffer.from(file.content, "utf8")
}
} catch {
// Last-resort fallback: binary
content = Buffer.from(file.content, "binary")
}
const command = new PutObjectCommand({
// We probably also want to support a separate bucket altogether for private files
// protected private_bucket_: string