Skip to content

Instantly share code, notes, and snippets.

@romach
Last active October 11, 2020 16:28
Show Gist options
  • Save romach/e7fb0aef997aaf73948742d406824ce6 to your computer and use it in GitHub Desktop.
Save romach/e7fb0aef997aaf73948742d406824ce6 to your computer and use it in GitHub Desktop.
Save video from Azure Storage
const azure = require('azure-storage');
const fs = require('fs');
const STORAGE_ACCOUNT_NAME = '<STORAGE_ACCOUNT_NAME>';
const STORAGE_ACCESS_KEY = '<STORAGE_ACCESS_KEY>';
const blobService = azure.createBlobService(STORAGE_ACCOUNT_NAME, STORAGE_ACCESS_KEY);
const containerName = "videos";
const videoPath = "SampleVideo_1280x720_1mb.mp4";
// retrieve video properties
blobService.getBlobProperties(containerName, videoPath, (err, properties) => {
if (err) {
console.log('Error occurred during connection to Azure storage')
return;
}
// Streams the video from Azure storage to file
const writeStream = fs.createWriteStream('SampleVideo_1280x720_1mb.mp4');
blobService.getBlobToStream(containerName, videoPath, writeStream, (error, result) => {
if (error) {
console.log(error);
} else {
console.log(result);
}
});
});
{
"name": "azure",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"azure-storage": "^2.10.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment