Provide same response format for front and datalake upload (#8809)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Nikolay Marchuk <nikolay.marchuk@hardcoreeng.com>
This commit is contained in:
Nikolay Marchuk 2025-05-02 13:06:52 +07:00 committed by GitHub
parent 31e1b31912
commit 7e710f04a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View File

@ -52,7 +52,7 @@ async function storageUpload (
storageAdapter: StorageAdapter, storageAdapter: StorageAdapter,
wsIds: WorkspaceIds, wsIds: WorkspaceIds,
file: UploadedFile file: UploadedFile
): Promise<string> { ): Promise<{ uuid: string, etag: string }> {
const uuid = file.name const uuid = file.name
const data = file.tempFilePath !== undefined ? fs.createReadStream(file.tempFilePath) : file.data const data = file.tempFilePath !== undefined ? fs.createReadStream(file.tempFilePath) : file.data
const resp = await ctx.with( const resp = await ctx.with(
@ -63,7 +63,7 @@ async function storageUpload (
) )
ctx.info('storage upload', resp) ctx.info('storage upload', resp)
return uuid return { uuid, etag: resp.etag }
} }
function getRange (range: string, size: number): [number, number] { function getRange (range: string, size: number): [number, number] {
@ -602,12 +602,19 @@ export function start (
res.status(403).send() res.status(403).send()
return return
} }
const uuid = await storageUpload(ctx, config.storageAdapter, workspaceDataId, file) const { uuid, etag } = await storageUpload(ctx, config.storageAdapter, workspaceDataId, file)
res.status(200).send([ res.status(200).send([
{ {
key: 'file', key: 'file',
id: uuid id: uuid,
metadata: {
name: uuid,
etag,
size: file.size,
contentType: file.mimetype,
lastModified: Date.now()
}
} }
]) ])
} catch (error: any) { } catch (error: any) {

View File

@ -237,7 +237,7 @@ export async function handleUploadFormData (
ctx.info('uploaded', { workspace, name, etag: metadata.etag, type: contentType }) ctx.info('uploaded', { workspace, name, etag: metadata.etag, type: contentType })
return { key, metadata } return { key, id: name, metadata }
} catch (err: any) { } catch (err: any) {
Analytics.handleError(err) Analytics.handleError(err)
const error = err instanceof Error ? err.message : String(err) const error = err instanceof Error ? err.message : String(err)