mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 11:59:51 +08:00
fix: do not create hash in frontend (#6788)
blob is already hashed in https://github.com/toeverything/AFFiNE/blob/6fdf45d4d064ebac9691a71abc800a90c5e6bfb9/packages/backend/server/src/plugins/copilot/resolver.ts#L294
This commit is contained in:
@@ -8,16 +8,6 @@ const TIMEOUT = 50000;
|
||||
|
||||
const client = new CopilotClient();
|
||||
|
||||
async function calculateBlobHash(blob: Blob) {
|
||||
const buffer = await blob.arrayBuffer();
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
return hashArray
|
||||
.map(byte => byte.toString(16).padStart(2, '0'))
|
||||
.join('')
|
||||
.slice(0, 32);
|
||||
}
|
||||
|
||||
export type TextToTextOptions = {
|
||||
docId: string;
|
||||
workspaceId: string;
|
||||
@@ -86,7 +76,7 @@ async function createSessionMessage({
|
||||
if (blob instanceof File) {
|
||||
return blob;
|
||||
} else {
|
||||
return new File([blob], await calculateBlobHash(blob), {
|
||||
return new File([blob], sessionId, {
|
||||
type: blob.type,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user