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:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user