azure-storage-file-share-ts 是什么?
azure-storage-file-share-ts 通过ShareServiceClient、ShareClient、目录和文件客户端管理Azure Files,包含文件预分配、范围传输、共享快照和SAS。接入时要区别Node文件接口、浏览器能力和服务实际认证条件。
中文说明由本站依据来源整理;英文原文保留在页面下方。
怎么接入你的 Agent?
- 定位完整 Skill 目录
打开本项目来源,核对
SKILL.md及其引用的脚本和资料。 - 交给你正在用的 Agent
在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。
- 确认识别,再做具体任务
让 Agent 回报安装目录和识别到的名称
azure-storage-file-share-ts,然后按本页使用示例提供材料。
装好以后,具体怎么用?
准备哪些材料
- 准备@azure/storage-file-share、认证依赖、file endpoint与share/路径;核对SDK版本、身份支持及必要客户端选项。源中的TokenCredential示例未覆盖完整环境前提。
会得到什么
- 平台和字节范围正确的TypeScript文件代码、快照访问与复制状态检查方式。
实际使用顺序
- 取得已有共享与目录,listFilesAndDirectories按kind区分文件/目录;创建嵌套路径前逐层核对父目录,不能把一个路径字符串当自动mkdir -p保证。
- create按内容字节长度分配,再用uploadRange写offset/length;中文文本用实际编码字节长度,不用String.length。Node可按所装API选择uploadFile/流和downloadToFile,浏览器不用Node文件路径/Buffer方案。
- 快照读取用withSnapshot(标识)访问特定视图;复制API返回形状按实际版本核对,不能假设startCopyFromURL一定是可pollUntilDone的poller。删除共享并包含快照与只删指定快照是不同动作。
从一个具体任务开始
本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。
复制一个具体任务
教学任务:使用 azure-storage-file-share-ts,为Node.js服务设计中文文本文件上传,先把UTF-8内容转Buffer,用buffer.length创建并uploadRange。保留目录层级、设置正确Content-Type,另外给出指定snapshot只读访问方案;只生成代码,不上传或删除共享。预期得到字节长度与快照范围准确的设计;本站未编译或访问共享。
使用条件与边界
- 源中部分rootDirectoryClient、uploadStream和copy poller写法需要按实际SDK公开API核对,不能宣称全部片段直接可编译。
- 源里的delete({deleteSnapshots:'include'})不应作为只删一个快照的通用示例,它涉及共享与快照范围。
常见问题
中文上传为什么按content.length会出问题?
文件长度和range长度按字节计算,JavaScript字符串长度不是UTF-8字节数。Node示例应先编码成Buffer,再使用buffer.length。
来源原文与资料状态
- 源文件
- 已保存 SKILL.md,抓取于 2026-11-16T12:36:35.145Z
- 中文使用说明
- 已针对下方源文件版本整理用途、用法和常见问题
- 安装与任务测试
- 本站未执行安装或任务测试
- 来源复核
- 本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料
.github/plugins/azure-sdk-typescript/skills/azure-storage-file-share-ts/SKILL.md · 抓取时间 2026-11-16T12:36:35.145Z
以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。
抓取成功不代表已完成安装或任务测试。
Azure File Share JavaScript/TypeScript SDK (@azure/storage-file-share) for SMB file share operations. Use for creating shares, managing directories, uploading/downloading files, and handling file metadata. Supports Azure Files SMB protocol scenarios. Triggers: "file share", "@azure/storage-file-share", "ShareServiceClient", "ShareClient", "SMB", "Azure Files".
查看源文件章节 / Source sections
- 原文:@azure/storage-file-share (TypeScript/JavaScript)
- 安装 / Installation
- 原文:Environment Variables
- 原文:Authentication
- 原文:Connection String (Simplest)
- 原文:StorageSharedKeyCredential (Node.js only)
- 原文:Microsoft Entra Token Credential
- 原文:SAS Token
- 原文:Client Hierarchy
- 原文:Share Operations
- 原文:Create Share
- 原文:List Shares
- 原文:Delete Share
- 原文:Get Share Properties
- 原文:Set Share Quota
- 原文:Directory Operations
- 原文:Create Directory
- 原文:List Directories and Files
- 原文:Delete Directory
- 原文:Check if Directory Exists
- 原文:File Operations
- 原文:Upload File (Simple)
- 原文:Upload File (Node.js - from local file)
- 原文:Upload File (Buffer)
- 原文:Upload File (Stream)
- 原文:Download File
- 原文:Download to File (Node.js)
- 原文:Download to Buffer (Node.js)
- 原文:Delete File
- 原文:Copy File
原文:@azure/storage-file-share (TypeScript/JavaScript)
SDK for Azure File Share operations — SMB file shares, directories, and file operations.
安装 / Installation
```bash npm install @azure/storage-file-share @azure/identity ``` **Current Version**: 12.x **Node.js**: >= 18.0.0
原文:Environment Variables
```bash AZURE_STORAGE_ACCOUNT_NAME=<account-name> AZURE_STORAGE_ACCOUNT_KEY=<account-key> # OR connection string AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;AccountName=... AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production ```
原文:Connection String (Simplest)
```typescript import { ShareServiceClient } from "@azure/storage-file-share"; const client = ShareServiceClient.fromConnectionString( process.env.AZURE_STORAGE_CONNECTION_STRING! ); ```
原文:StorageSharedKeyCredential (Node.js only)
```typescript import { ShareServiceClient, StorageSharedKeyCredential } from "@azure/storage-file-share"; const accountName = process.env.AZURE_STORAGE_ACCOUNT_NAME!; const accountKey = process.env.AZURE_STORAGE_ACCOUNT_KEY!; const sharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey); const client = new ShareServiceClient( `https://${accountName}.file.core.windows.net`, sharedKeyCredential ); ```
原文:Microsoft Entra Token Credential
```typescript import { ShareServiceClient } from "@azure/storage-file-share"; import { DefaultAzureCredential, ManagedIdentityCredential } from "@azure/identity"; // Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential> const credential = new DefaultAzureCredential({requiredEnvVars: ["AZURE_TOKEN_CREDENTIALS"]}); // Or use a specific credential directly in production: // See https://learn.microsoft.com/javascript/api/overview/azure/identity-readme?view=azure-node-latest#credential-classes // const credential = new ManagedIdentityCredential(); const accountName = process.env.AZURE_STORAGE_ACCOUNT_NAME!; const client = new ShareServiceClient( `https://${accountName}.file.core.windows.net`, credential ); ```
文件 SHA256:9a0e4d4a1940c40420d292b311bf23c62e7b855506459984382d9dfcae3f140f
仓库许可证记录:MIT;skill-declaration-captured-not-interpreted,查看来源。
Azure File Share JavaScript/TypeScript SDK (@azure/storage-file-share) for SMB file share operations. Use for creating shares, managing directories, uploading/downloading files, and handling file metadata. Supports Azure Files SMB protocol scenarios. Triggers: "file share", "@azure/storage-file-share", "ShareServiceClient", "ShareClient", "SMB", "Azure Files".
历史收录数据
| 来源仓库 | microsoft/skills |
|---|---|
| Skill源路径 | .github/plugins/azure-sdk-typescript/skills/azure-storage-file-share-ts/SKILL.md |
安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。
