Created
June 26, 2017 01:10
-
-
Save timothytavarez/7b2ffd859b5ab6267749220249d406fd to your computer and use it in GitHub Desktop.
Azure Blob Storage Uploader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const azure = require('azure-storage'); | |
const uuidv1 = require('uuid/v1'); | |
const path = require('path'); | |
const blobService = azure.createBlobService('azuredotjsblob', // fill in your value here. | |
'connection_key', // fill in your value here. | |
'blob_service_endpoint'); // fill in your value here. | |
let container = 'imagecontainer', // fill in your value here. | |
upload = process.argv[2], | |
extName = path.extname(upload), | |
blobName = uuidv1() + extName; | |
function uploadToBlob() { | |
blobService.createBlockBlobFromLocalFile(container, blobName, upload, function (error, result) { | |
if (!error) { | |
let id = blobService.getUrl(container, blobName); | |
console.log(`${blobName} successfully uploaded to Azure Blob Storage. URL:`) | |
return console.log(id); | |
} | |
return console.error(error); | |
}) | |
} | |
uploadToBlob(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment