Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix enforcing chunkSize when TUS is not enabled and update the default TUS_CHUNK_SIZE to 8mb #24002

Merged
merged 13 commits into from
Nov 19, 2024
Merged
Prev Previous commit
Next Next commit
fix typings
  • Loading branch information
ComfortablyCoding committed Nov 7, 2024
commit ad814d2346494896753cb82a60b2adc89de8627d
2 changes: 1 addition & 1 deletion packages/storage-driver-azure/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type DriverAzureConfig = {
endpoint?: string;
tus?: {
enabled: boolean;
chunkSize: number;
chunkSize?: number;
};
};

Expand Down
2 changes: 1 addition & 1 deletion packages/storage-driver-cloudinary/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type DriverCloudinaryConfig = {
accessMode: 'public' | 'authenticated';
tus?: {
enabled: boolean;
chunkSize: number;
chunkSize?: number;
};
};

Expand Down
7 changes: 5 additions & 2 deletions packages/storage-driver-gcs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type DriverGCSConfig = {
apiEndpoint?: string;
tus?: {
enabled: boolean;
chunkSize: number;
chunkSize?: number;
};
};

Expand All @@ -37,7 +37,10 @@ export class DriverGCS implements TusDriver {
this.preferredChunkSize = tus?.chunkSize || DEFAULT_CHUNK_SIZE;

// chunkSize must be powers of 2 starting at 256kb
if (tus?.enabled && (tus.chunkSize < MINIMUM_CHUNK_SIZE || Math.log2(tus.chunkSize) % 1 !== 0)) {
if (
tus?.enabled &&
(this.preferredChunkSize < MINIMUM_CHUNK_SIZE || Math.log2(this.preferredChunkSize) % 1 !== 0)
) {
throw new Error('Invalid chunkSize provided');
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-driver-supabase/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type DriverSupabaseConfig = {
root?: string;
tus?: {
enabled: boolean;
chunkSize: number;
chunkSize?: number;
};
};

Expand Down
Loading