Skip to content

Commit

Permalink
feat: --tus-chunk-size
Browse files Browse the repository at this point in the history
  • Loading branch information
WcaleNieWolny committed Jan 3, 2025
1 parent e769607 commit c2cd3c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/bundle/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ interface Options extends OptionsBase {
packageJson?: string
dryUpload?: boolean
nodeModules?: string
tusChunkSize?: number
}

type SupabaseType = Awaited<ReturnType<typeof createSupabaseClient>>
Expand Down Expand Up @@ -369,7 +370,7 @@ async function uploadBundleToCapgoCloud(apikey: string, supabase: SupabaseType,
else {
log.info(`Uploading bundle with TUS protocol`)
}
await uploadTUS(apikey, zipped, orgId, appid, bundle, spinner, localConfig)
await uploadTUS(apikey, zipped, orgId, appid, bundle, spinner, localConfig, options.tusChunkSize)
isTus = true
const filePath = `orgs/${orgId}/apps/${appid}/${bundle}.zip`
const { error: changeError } = await supabase
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ bundle
.option('--timeout <timeout>', 'Timeout for the upload process in seconds')
.option('--multipart', 'Uses multipart protocol to upload data to S3, Deprecated, use tus instead')
.option('--tus', 'Upload the bundle using TUS to Capgo cloud')
.option('--tus-chunk-size <tusChunkSize>', 'Chunk size for the TUS upload')
.option('--partial', 'Upload partial files to Capgo cloud')
.option('--encrypted-checksum <encryptedChecksum>', 'An encrypted checksum (signature). Used only when uploading an external bundle.')
.option('--package-json <packageJson>', 'A path to package.json. Usefull for monorepos')
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ export async function zipFileWindows(filePath: string): Promise<Buffer> {
return zip.toBuffer()
}

export async function uploadTUS(apikey: string, data: Buffer, orgId: string, appId: string, name: string, spinner: ReturnType<typeof spinnerC>, localConfig: CapgoConfig): Promise<boolean> {
export async function uploadTUS(apikey: string, data: Buffer, orgId: string, appId: string, name: string, spinner: ReturnType<typeof spinnerC>, localConfig: CapgoConfig, chunkSize?: number): Promise<boolean> {
return new Promise((resolve, reject) => {
sendEvent(apikey, {
channel: 'app',
Expand All @@ -759,6 +759,7 @@ export async function uploadTUS(apikey: string, data: Buffer, orgId: string, app
const upload = new tus.Upload(data as any, {
endpoint: `${localConfig.hostFilesApi}/files/upload/attachments/`,
// parallelUploads: multipart,
chunkSize: chunkSize || Number.POSITIVE_INFINITY,
metadataForPartialUploads: {
filename: `orgs/${orgId}/apps/${appId}/${name}.zip`,
filetype: 'application/gzip',
Expand Down

0 comments on commit c2cd3c1

Please sign in to comment.