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
2 changes: 2 additions & 0 deletions packages/core/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export class UploadAPI {
onChange,
onError,
autoUpload = true,
projectID,
} = config

let response: AxiosResponse<InitUploadResponse> | null = null
Expand All @@ -297,6 +298,7 @@ export class UploadAPI {
name: file.name,
size: file.size,
type: outputType,
projectID,
})
} catch (error: unknown) {
UploadAPI.reportError(error, onError, null)
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export type ApiConfig = {
onChange: ChangeCallback
onError: ErrorCallback
autoUpload?: boolean
/** @experimental Projects is a experimental feature, not rolled out yet */
projectID?: string
}

export type UploadConfig = {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/server/routes/initUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const initUpload = async (
size: number,
serviceToken: string,
type: OutputType | null,
projectID?: string,
) => {
const output = type ? { type } : undefined

Expand All @@ -24,6 +25,7 @@ export const initUpload = async (
size,
supported_upload_types: ['s3_multipart'],
output,
project_id: projectID,
},
})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/example/app/api/ingest/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export async function POST(request: NextRequest) {
)
}

const { name, size, type } = await request.json()
const data = await initUpload(name, size, serviceToken, type)
const { name, size, type, projectID } = await request.json()
const data = await initUpload(name, size, serviceToken, type, projectID)

return NextResponse.json(data, { status: data.status })
}
1 change: 1 addition & 0 deletions packages/example/app/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const Content = () => {
initializeURI: datasetID ? `/api/${datasetID}/ingest` : '/api/ingest',
getProcessURI: (id) => `/api/ingest/${id}/process`,
getCancelURI: (id) => `/api/ingest/${id}/cancel`,
// projectID: 'PROJECT_ID', // Optional: specify a project ID (not publicly available yet)
}

// The UploadAPI class is a wrapper around the upload process.
Expand Down
Loading