mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-10 09:22:23 +00:00
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
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:
parent
31e1b31912
commit
7e710f04a9
@ -52,7 +52,7 @@ async function storageUpload (
|
||||
storageAdapter: StorageAdapter,
|
||||
wsIds: WorkspaceIds,
|
||||
file: UploadedFile
|
||||
): Promise<string> {
|
||||
): Promise<{ uuid: string, etag: string }> {
|
||||
const uuid = file.name
|
||||
const data = file.tempFilePath !== undefined ? fs.createReadStream(file.tempFilePath) : file.data
|
||||
const resp = await ctx.with(
|
||||
@ -63,7 +63,7 @@ async function storageUpload (
|
||||
)
|
||||
|
||||
ctx.info('storage upload', resp)
|
||||
return uuid
|
||||
return { uuid, etag: resp.etag }
|
||||
}
|
||||
|
||||
function getRange (range: string, size: number): [number, number] {
|
||||
@ -602,12 +602,19 @@ export function start (
|
||||
res.status(403).send()
|
||||
return
|
||||
}
|
||||
const uuid = await storageUpload(ctx, config.storageAdapter, workspaceDataId, file)
|
||||
const { uuid, etag } = await storageUpload(ctx, config.storageAdapter, workspaceDataId, file)
|
||||
|
||||
res.status(200).send([
|
||||
{
|
||||
key: 'file',
|
||||
id: uuid
|
||||
id: uuid,
|
||||
metadata: {
|
||||
name: uuid,
|
||||
etag,
|
||||
size: file.size,
|
||||
contentType: file.mimetype,
|
||||
lastModified: Date.now()
|
||||
}
|
||||
}
|
||||
])
|
||||
} catch (error: any) {
|
||||
|
@ -237,7 +237,7 @@ export async function handleUploadFormData (
|
||||
|
||||
ctx.info('uploaded', { workspace, name, etag: metadata.etag, type: contentType })
|
||||
|
||||
return { key, metadata }
|
||||
return { key, id: name, metadata }
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
const error = err instanceof Error ? err.message : String(err)
|
||||
|
Loading…
Reference in New Issue
Block a user