mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-29 06:43:02 +00:00
parent
93bd34113c
commit
d6ef28d4ca
1 changed files with 4 additions and 5 deletions
|
@ -301,12 +301,14 @@ export const uploadFile = async (user?: UserToken, { path, name, blob }: UploadO
|
||||||
};
|
};
|
||||||
|
|
||||||
export const uploadUrl = async (user: UserToken, url: string) => {
|
export const uploadUrl = async (user: UserToken, url: string) => {
|
||||||
let file: any;
|
let resolve: unknown;
|
||||||
|
const file = new Promise(ok => resolve = ok);
|
||||||
const marker = Math.random().toString();
|
const marker = Math.random().toString();
|
||||||
|
|
||||||
const ws = await connectStream(user, 'main', (msg) => {
|
const ws = await connectStream(user, 'main', (msg) => {
|
||||||
if (msg.type === 'urlUploadFinished' && msg.body.marker === marker) {
|
if (msg.type === 'urlUploadFinished' && msg.body.marker === marker) {
|
||||||
file = msg.body.file;
|
ws.close();
|
||||||
|
resolve(msg.body.file);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -316,9 +318,6 @@ export const uploadUrl = async (user: UserToken, url: string) => {
|
||||||
force: true,
|
force: true,
|
||||||
}, user);
|
}, user);
|
||||||
|
|
||||||
await sleep(7000);
|
|
||||||
ws.close();
|
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue