Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes TypeScript in upload-to-storage #2289

Merged
merged 1 commit into from
Feb 25, 2021
Merged
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
20 changes: 10 additions & 10 deletions scripts/azpipelines/upload-to-storage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// eslint-disable no-console
const fs = require("fs");
const path = require("path");
const azureStorage = require("azure-storage");
const { getManifest, getContainerName } = require("./utils");
const crypto = require("crypto");
import * as fs from "fs";
import * as path from "path";
import * as AzureStorage from "azure-storage";
import { getManifest, getContainerName } from "./utils";
import * as crypto from "crypto";

const storageAccountName = process.env.AZURE_STORAGE_ACCOUNT;
const storageAccountKey = process.argv[2];
Expand All @@ -17,16 +17,16 @@ if (!storageAccountKey) {
}

console.log("Uploading to storage account:", storageAccountName);
const blobService = azureStorage.createBlobService(storageAccountName, storageAccountKey);
const blobService = AzureStorage.createBlobService(storageAccountName, storageAccountKey);

function computeFileMd5(filename) {
const data = fs.readFileSync(filename);
return crypto.createHash("md5").update(data).digest("base64");
}

async function getBlob(container, blobName) {
async function getBlob(container, blobName): Promise<AzureStorage.BlobService.BlobResult> {
return new Promise((resolve, reject) => {
blobService.getBlobProperties(container, blobName, (error, result, response) => {
blobService.getBlobProperties(container, blobName, (error, result) => {
if (error) {
return reject(error);
}
Expand All @@ -37,9 +37,9 @@ async function getBlob(container, blobName) {
}

async function createBlobFromLocalFile(container, filename, blobName, override = false) {
const options = {};
const options: AzureStorage.BlobService.CreateBlockBlobRequestOptions = {};
if (!override) {
options.accessConditions = azureStorage.AccessCondition.generateIfNotExistsCondition();
options.accessConditions = AzureStorage.AccessCondition.generateIfNotExistsCondition();
}

return new Promise((resolve, reject) => {
Expand Down