in src/commands/uploadFiles.ts [25:84]
export async function uploadFiles(
context: IActionContext,
treeItem?: BlobContainerTreeItem | FileShareTreeItem,
uris?: Uri[],
notificationProgress?: NotificationProgress,
cancellationToken?: CancellationToken,
destinationDirectory?: string
): Promise<IAzCopyResolution> {
const calledFromUploadToAzureStorage: boolean = uris !== undefined;
if (uris === undefined) {
uris = await context.ui.showOpenDialog(
{
canSelectFiles: true,
canSelectFolders: false,
canSelectMany: true,
defaultUri: lastUriUpload,
filters: {
"All files": ['*']
},
openLabel: upload
}
);
}
treeItem = treeItem || <BlobContainerTreeItem | FileShareTreeItem>(await ext.tree.showTreeItemPicker([BlobContainerTreeItem.contextValue, FileShareTreeItem.contextValue], context));
destinationDirectory = await getDestinationDirectory(context, destinationDirectory);
let urisToUpload: Uri[] = [];
if (!calledFromUploadToAzureStorage) {
const overwriteChoice: { choice: OverwriteChoice | undefined } = { choice: undefined };
for (const uri of uris) {
const destPath: string = convertLocalPathToRemotePath(uri.fsPath, destinationDirectory);
if (!await AzExtFsExtra.isDirectory(uri) && await checkCanUpload(context, destPath, overwriteChoice, treeItem)) {
// Don't allow directories to sneak in https://github.com/microsoft/vscode-azurestorage/issues/803
urisToUpload.push(uri);
}
}
} else {
urisToUpload = uris;
}
if (!urisToUpload.length) {
// No URIs to upload and no errors to report
return { errors: [] };
}
if (notificationProgress && cancellationToken) {
return await uploadFilesHelper(context, treeItem, urisToUpload, notificationProgress, cancellationToken, destinationDirectory, calledFromUploadToAzureStorage);
} else {
const title: string = getUploadingMessage(treeItem.label);
const resolution: IAzCopyResolution = await window.withProgress({ cancellable: true, location: ProgressLocation.Notification, title }, async (newNotificationProgress, newCancellationToken) => {
return await uploadFilesHelper(context, nonNullValue(treeItem), urisToUpload, newNotificationProgress, newCancellationToken, nonNullValue(destinationDirectory), calledFromUploadToAzureStorage);
});
if (!calledFromUploadToAzureStorage) {
showUploadSuccessMessage(treeItem.label);
}
return resolution;
}
}