Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azure/storage-file-share

Package Overview
Dependencies
Maintainers
2
Versions
376
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/storage-file-share

Microsoft Azure Storage SDK for JavaScript - File

  • 12.26.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is @azure/storage-file-share?

@azure/storage-file-share is an Azure SDK package that allows developers to interact with Azure File Storage. It provides functionalities to manage file shares, directories, and files in Azure Storage accounts.

What are @azure/storage-file-share's main functionalities?

Create a File Share

This feature allows you to create a new file share in your Azure Storage account. The code sample demonstrates how to use the ShareServiceClient to create a file share named 'my-new-share'.

const { ShareServiceClient } = require('@azure/storage-file-share');
const connectionString = 'Your_Connection_String';
const serviceClient = ShareServiceClient.fromConnectionString(connectionString);
async function createShare() {
  const shareName = 'my-new-share';
  const shareClient = serviceClient.getShareClient(shareName);
  await shareClient.create();
  console.log(`Share created: ${shareName}`);
}
createShare();

Upload a File

This feature allows you to upload a file to a specified file share and directory. The code sample shows how to upload a text file named 'example.txt' with the content 'Hello, Azure!' to the root directory of 'my-new-share'.

const { ShareServiceClient } = require('@azure/storage-file-share');
const fs = require('fs');
const connectionString = 'Your_Connection_String';
const serviceClient = ShareServiceClient.fromConnectionString(connectionString);
async function uploadFile() {
  const shareName = 'my-new-share';
  const directoryName = '';
  const fileName = 'example.txt';
  const fileContent = 'Hello, Azure!';
  const shareClient = serviceClient.getShareClient(shareName);
  const directoryClient = shareClient.getDirectoryClient(directoryName);
  const fileClient = directoryClient.getFileClient(fileName);
  await fileClient.create(fileContent.length);
  await fileClient.uploadRange(fileContent, 0, fileContent.length);
  console.log(`File uploaded: ${fileName}`);
}
uploadFile();

List Files and Directories

This feature allows you to list all files and directories within a specified directory of a file share. The code sample demonstrates how to list entities in the root directory of 'my-new-share'.

const { ShareServiceClient } = require('@azure/storage-file-share');
const connectionString = 'Your_Connection_String';
const serviceClient = ShareServiceClient.fromConnectionString(connectionString);
async function listFilesAndDirectories() {
  const shareName = 'my-new-share';
  const directoryName = '';
  const shareClient = serviceClient.getShareClient(shareName);
  const directoryClient = shareClient.getDirectoryClient(directoryName);
  let iter = directoryClient.listFilesAndDirectories();
  let entity = await iter.next();
  while (!entity.done) {
    console.log(`Entity: ${entity.value.name}`);
    entity = await iter.next();
  }
}
listFilesAndDirectories();

Other packages similar to @azure/storage-file-share

Keywords

FAQs

Package last updated on 20 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc