Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let blobs = Object.keys(changes).map((key) => {
let documentChange = {
id: this.sanitizeKey(key),
realId: key,
document: changes[key]
};
let payload = JSON.stringify(documentChange);
let options = {
accessConditions: changes[key].eTag === '*' ? azure.AccessCondition.generateEmptyCondition() : azure.AccessCondition.generateIfMatchCondition(changes[key].eTag),
parallelOperationThreadCount: 4
};
return {
id: documentChange.id,
data: payload,
options: options
};
});
// A block blob can be uploaded using a single PUT operation or divided into multiple PUT block operations
async function createBlobFromLocalFile(container, filename, blobName, override = false) {
const options = {};
if (!override) {
options.accessConditions = azureStorage.AccessCondition.generateIfNotExistsCondition();
}
return new Promise((resolve, reject) => {
blobService.createBlockBlobFromLocalFile(container, blobName, filename, options,
(error, result, response) => {
if (error) {
reject(error);
return;
}
console.log("Uploaded", result, response);
resolve(result);
});
});
}
}[] = Object.keys(changes).map((key: string) => {
const documentChange: DocumentStoreItem = {
id: this.sanitizeKey(key),
realId: key,
document: changes[key]
};
const payload: string = JSON.stringify(documentChange);
const options: azure.BlobService.CreateBlobRequestOptions = {
accessConditions: changes[key].eTag === '*' ?
azure.AccessCondition.generateEmptyCondition() : azure.AccessCondition.generateIfMatchCondition(changes[key].eTag),
parallelOperationThreadCount: 4
};
return {
id: documentChange.id,
data: payload,
options: options
};
});