Skip to content

Commit c3718ee

Browse files
committed
fix: align media type handling logic with the actual BE behaviour
1 parent 144d332 commit c3718ee

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/strategies/export-version.strategy.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ function extractTypeAndSubtype(type: string): string {
4444

4545
async function prepareData(file: File): Promise<ZippableDocument['data']> {
4646
switch (extractTypeAndSubtype(file.type)) {
47-
// BE responds with either 'text/plain' or 'application/octet-stream', which is not precise enough
47+
// BE responds with 'text/plain' for all textual files and a more precise content-type in other cases
48+
// however, just in case, other processable types are also listed here
4849
case 'text/plain':
4950
case 'application/json':
51+
case 'application/yaml':
5052
case 'text/markdown':
5153
return await file.text()
54+
default:
5255
case 'application/octet-stream':
5356
return ''
54-
default:
55-
throw new Error(`File media type ${file.type} is not supported`)
5657
}
5758
}
5859

test/projects/export/Document.docx

16.8 KB
Binary file not shown.

test/projects/export/Test.png

4.38 KB
Loading

test/projects/export/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
"labels": [],
1717
"commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd"
1818
},
19+
{
20+
"fileId": "Document.docx",
21+
"publish": true,
22+
"commitId": "55d4a4c5008207d5243d511a27601ba1f2ace0c1"
23+
},
24+
{
25+
"fileId": "Test.png",
26+
"publish": true,
27+
"commitId": "55d4a4c5008207d5243d511a27601ba1f2ace0c1"
28+
},
1929
{
2030
"fileId": "README.md",
2131
"publish": true,

0 commit comments

Comments
 (0)