Skip to content

Commit e78aae3

Browse files
committed
fix: Do not block if the filetype is unknown to the browser
Signed-off-by: Julius Härtl <[email protected]>
1 parent 4188caf commit e78aae3

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

__tests__/utils/upload.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ describe('Get chunk from file', () => {
3535
expect(chunk.size).toBe(10 * 1024 * 1024)
3636
})
3737

38-
test('Chunking an invalid file', () => {
38+
test('Chunking an invalid file', async () => {
3939
const blob = new Blob([new ArrayBuffer(5 * 1024 * 1024)])
4040
const file = new File([blob as BlobPart], 'image.jpg')
4141

42-
expect(getChunk(file, 0, 10 * 1024 * 1024)).rejects.toEqual(new Error('Unknown file type'))
42+
const chunk = await getChunk(file, 0, 10 * 1024 * 1024)
43+
expect(chunk.size).toBe(5 * 1024 * 1024)
44+
expect(chunk.type).toBe('application/octet-stream')
45+
4346
})
4447
})
4548

lib/utils/upload.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ export const uploadData = async function(url: string, uploadData: UploadData, si
4242
* garbage collection
4343
*/
4444
export const getChunk = function(file: File, start: number, length: number): Promise<Blob> {
45-
if (!file.type) {
46-
return Promise.reject(new Error('Unknown file type'))
47-
}
48-
4945
// Since we use a global FileReader, we need to only read one chunk at a time
5046
return readerLimit(() => new Promise((resolve, reject) => {
5147
reader.onload = () => {

0 commit comments

Comments
 (0)