Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/api/node/extHostDownloadService.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { join } from '../../../base/common/path.js';
7
import { tmpdir } from 'os';
8
import { generateUuid } from '../../../base/common/uuid.js';
9
import { IExtHostCommands } from '../common/extHostCommands.js';
10
import { Disposable } from '../../../base/common/lifecycle.js';
11
import { MainContext } from '../common/extHost.protocol.js';
12
import { URI } from '../../../base/common/uri.js';
13
import { IExtHostRpcService } from '../common/extHostRpcService.js';
14
15
export class ExtHostDownloadService extends Disposable {
16
17
constructor(
18
@IExtHostRpcService extHostRpc: IExtHostRpcService,
19
@IExtHostCommands commands: IExtHostCommands
20
) {
21
super();
22
23
const proxy = extHostRpc.getProxy(MainContext.MainThreadDownloadService);
24
25
commands.registerCommand(false, '_workbench.downloadResource', async (resource: URI): Promise<any> => {
26
const location = URI.file(join(tmpdir(), generateUuid()));
27
await proxy.$download(resource, location);
28
return location;
29
});
30
}
31
}
32
33