Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions __tests__/utils/upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ describe('Get chunk from file', () => {
expect(chunk.size).toBe(10 * 1024 * 1024)
})

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

expect(getChunk(file, 0, 10 * 1024 * 1024)).rejects.toEqual(new Error('Unknown file type'))
const chunk = await getChunk(file, 0, 10 * 1024 * 1024)
expect(chunk.size).toBe(5 * 1024 * 1024)
expect(chunk.type).toBe('application/octet-stream')

})
})

Expand Down
4 changes: 0 additions & 4 deletions lib/utils/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ export const uploadData = async function(url: string, uploadData: UploadData, si
* garbage collection
*/
export const getChunk = function(file: File, start: number, length: number): Promise<Blob> {
if (!file.type) {
return Promise.reject(new Error('Unknown file type'))
}

// Since we use a global FileReader, we need to only read one chunk at a time
return readerLimit(() => new Promise((resolve, reject) => {
reader.onload = () => {
Expand Down