Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/BlobContainerFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,16 @@ export class BlobContainerFS implements vscode.FileSystemProvider {
const { blobClient } = await this.getBlobClients(uri, storageAccount, accountKey, credentials);
const { baseName } = this.parseUri(uri);

const exists = await blobClient.exists();
let existingProperties: BlobGetPropertiesResponse | undefined;
try {
existingProperties = await blobClient.getProperties();
} catch (error) {
if (parseError(error).errorType !== "404") {
throw error;
}
}
const exists = existingProperties !== undefined;

if (!options.create && !exists) {
throw vscode.FileSystemError.FileNotFound(uri);
} else if (options.create && !options.overwrite && exists) {
Expand All @@ -431,9 +440,10 @@ export class BlobContainerFS implements vscode.FileSystemProvider {
} else {
progress.report({ message: localize('creatingBlob', `Creating blob {0}...`, baseName) });
}

await blobClient.getBlockBlobClient().uploadData(content, {
blobHTTPHeaders: {
blobContentType: mime.getType(uri.path) || undefined
blobContentType: existingProperties?.contentType || mime.getType(uri.path) || undefined
}
});
});
Expand Down
Loading