Path: blob/main/src/vs/workbench/api/node/extHostDownloadService.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { join } from '../../../base/common/path.js';6import { tmpdir } from 'os';7import { generateUuid } from '../../../base/common/uuid.js';8import { IExtHostCommands } from '../common/extHostCommands.js';9import { Disposable } from '../../../base/common/lifecycle.js';10import { MainContext } from '../common/extHost.protocol.js';11import { URI } from '../../../base/common/uri.js';12import { IExtHostRpcService } from '../common/extHostRpcService.js';1314export class ExtHostDownloadService extends Disposable {1516constructor(17@IExtHostRpcService extHostRpc: IExtHostRpcService,18@IExtHostCommands commands: IExtHostCommands19) {20super();2122const proxy = extHostRpc.getProxy(MainContext.MainThreadDownloadService);2324commands.registerCommand(false, '_workbench.downloadResource', async (resource: URI): Promise<any> => {25const location = URI.file(join(tmpdir(), generateUuid()));26await proxy.$download(resource, location);27return location;28});29}30}313233