Skip to content

Commit

Permalink
Update FileLike
Browse files Browse the repository at this point in the history
  • Loading branch information
a179346 committed Mar 8, 2024
1 parent 8b77050 commit 614b67b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nextjs-chunk-upload-action",
"version": "8.0.0",
"version": "8.1.0",
"description": "Uploading large files with chunking using server action in Next.js",
"main": "dist/index.js",
"scripts": {
Expand Down
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
* [API Reference]: https://github.com/a179346/nextjs-chunk-upload-action/blob/main/docs/api-reference.md
*/

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

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

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

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

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

0 comments on commit 614b67b

Please sign in to comment.