mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-11-24 23:26:29 +09:00
parent
93bd34113c
commit
d6ef28d4ca
@ -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 New Issue
Block a user