Skip to content

Commit 614b67b

Browse files
committed
Update FileLike
1 parent 8b77050 commit 614b67b

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-chunk-upload-action",
3-
"version": "8.0.0",
3+
"version": "8.1.0",
44
"description": "Uploading large files with chunking using server action in Next.js",
55
"main": "dist/index.js",
66
"scripts": {

src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
* [API Reference]: https://github.com/a179346/nextjs-chunk-upload-action/blob/main/docs/api-reference.md
99
*/
1010

11-
export interface FileLike {
12-
readonly size: number;
13-
slice(start?: number, end?: number, contentType?: string): Blob;
14-
}
11+
export type FileLike = Pick<File, 'size' | 'slice'>;
1512

1613
export type Primitive = string | boolean | number | undefined | null;
1714

@@ -276,6 +273,8 @@ export class ChunkUploader<TMetadata extends Metadata> {
276273

277274
protected _validateOptions(options: ChunkUploaderOptions<TMetadata>) {
278275
if (!options.file) throw new Error('File is required');
276+
if (typeof options.file.size !== 'number') throw new Error('File size must be a number');
277+
if (typeof options.file.slice !== 'function') throw new Error('File slice must be a function');
279278

280279
if (typeof options.onChunkUpload !== 'function')
281280
throw new Error('onChunkUpload must be a function');

0 commit comments

Comments
 (0)