Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

321
Views
Upload a image to Microsoft Azure Blob Storage with node js

I am trying to upload a image to my blob storage but it upload text of the file path instead of image


const { BlobServiceClient, StorageSharedKeyCredential } = require("@azure/storage-blob");


const account = "<account name hided";
const accountKey = "<key hided>";

const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);
const blobServiceClient = new BlobServiceClient(
    `https://${account}.blob.core.windows.net`,
    sharedKeyCredential
);


var containerName = 'democontainer1';

async function createContainer() {
    const containerClient = blobServiceClient.getContainerClient(containerName);

    var blobName = "newblob" + new Date().getTime();
    var filePath = "./newblob.jpg";

    const blockBlobClient = containerClient.getBlockBlobClient(blobName);

    const uploadBlobResponse = await blockBlobClient.upload(filePath, filePath.length);
    console.log(`Upload block blob ${blobName} successfully`, uploadBlobResponse.requestId);
}

createContainer();

I want like this :

enter image description here

But the output is :

img

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Please change the following line of code:

const uploadBlobResponse = await blockBlobClient.upload(filePath, filePath.length);

to

const uploadBlobResponse = await blockBlobClient.uploadFile(filePath);

and you should see proper blob being uploaded.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!