fix(core): svg blob syncing issue (#4886)

This commit is contained in:
Peng Xiao
2023-11-10 13:32:51 +08:00
committed by GitHub
parent 2117d6b232
commit 5c2d958e2b
6 changed files with 120 additions and 19 deletions
@@ -9,6 +9,7 @@ import { fetcher } from '@affine/workspace/affine/gql';
import type { BlobStorage } from '@blocksuite/store';
import { predefinedStaticFiles } from './local-static-storage';
import { bufferToBlob } from './util';
export const createCloudBlobStorage = (workspaceId: string): BlobStorage => {
return {
@@ -17,15 +18,15 @@ export const createCloudBlobStorage = (workspaceId: string): BlobStorage => {
const suffix = predefinedStaticFiles.includes(key)
? `/static/${key}`
: `/api/workspaces/${workspaceId}/blobs/${key}`;
return fetchWithTraceReport(
runtimeConfig.serverUrlPrefix + suffix
).then(res => {
).then(async res => {
if (!res.ok) {
// status not in the range 200-299
return null;
}
// todo: shall we add svg type here if it is missing?
return res.blob();
return bufferToBlob(await res.arrayBuffer());
});
},
set: async (key, value) => {