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) => {
|
||||
let file: any;
|
||||
let resolve: unknown;
|
||||
const file = new Promise(ok => resolve = ok);
|
||||
const marker = Math.random().toString();
|
||||
|
||||
const ws = await connectStream(user, 'main', (msg) => {
|
||||
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,
|
||||
}, user);
|
||||
|
||||
await sleep(7000);
|
||||
ws.close();
|
||||
|
||||
return file;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue