다음을 통해 공유


ShareFileClient class

ShareFileClient는 Azure Storage 파일의 URL을 나타냅니다.

Extends

StorageClient

생성자

ShareFileClient(string, Credential | TokenCredential, ShareClientOptions)

ShareFileClient의 인스턴스를 만듭니다.

ShareFileClient(string, Pipeline, ShareClientConfig)

ShareFileClient의 인스턴스를 만듭니다.

속성

name

파일의 이름입니다.

path

파일의 전체 경로

shareName

이 파일 클라이언트에 해당하는 공유 이름

상속된 속성

accountName
url

URL 문자열 값입니다.

메서드

abortCopyFromURL(string, FileAbortCopyFromURLOptions)

보류 중인 파일 복사 작업을 중단하고 길이가 0인 대상 파일과 전체 메타데이터를 남깁니다.

https://learn.microsoft.com/rest/api/storageservices/abort-copy-file 참조

clearRange(number, number, FileClearRangeOptions)

지정된 범위를 지우고 해당 범위에 대한 스토리지에 사용되는 공간을 해제합니다.

create(number, FileCreateOptions)

새 파일을 만들거나 파일을 대체합니다. 콘텐츠가 없는 파일만 초기화합니다.

https://learn.microsoft.com/rest/api/storageservices/create-file 참조

createHardLink(string, FileCreateHardLinkOptions)

NFS만 해당됩니다. 경로로 지정된 파일 파일에 대한 하드 링크를 만듭니다.

createSymbolicLink(string, FileCreateSymbolicLinkOptions)

NFS만 해당됩니다. 기호 링크를 만듭니다.

delete(FileDeleteOptions)

스토리지 계정에서 파일을 제거합니다. 파일이 성공적으로 삭제되면 스토리지 계정의 인덱스에서 즉시 제거되고 클라이언트가 더 이상 액세스할 수 없습니다. 파일의 데이터는 나중에 가비지 수집 중에 서비스에서 제거됩니다.

SMB 클라이언트에서 파일이 열려 있으면 상태 코드 409(충돌) 및 오류 코드 SharingViolation으로 파일 삭제가 실패합니다.

공유의 읽기 전용 복사본인 공유 스냅샷에서는 파일 삭제가 지원되지 않습니다. 공유 스냅샷에서 이 작업을 수행하려고 하면 400(InvalidQueryParameterValue)으로 실패합니다.

https://learn.microsoft.com/rest/api/storageservices/delete-file2 참조

deleteIfExists(FileDeleteOptions)

파일이 있는 경우 스토리지 계정에서 파일을 제거합니다. 파일이 성공적으로 삭제되면 스토리지 계정의 인덱스에서 즉시 제거되고 클라이언트가 더 이상 액세스할 수 없습니다. 파일의 데이터는 나중에 가비지 수집 중에 서비스에서 제거됩니다.

SMB 클라이언트에서 파일이 열려 있으면 상태 코드 409(충돌) 및 오류 코드 SharingViolation으로 파일 삭제가 실패합니다.

공유의 읽기 전용 복사본인 공유 스냅샷에서는 파일 삭제가 지원되지 않습니다. 공유 스냅샷에서 이 작업을 수행하려고 하면 400(InvalidQueryParameterValue)으로 실패합니다.

https://learn.microsoft.com/rest/api/storageservices/delete-file2 참조

download(number, number, FileDownloadOptions)

메타데이터 및 속성을 포함하여 시스템에서 파일을 읽거나 다운로드합니다.

  • Node.js데이터는 읽기 가능한 스트림 readableStreamBody 반환됩니다.
  • 브라우저에서 데이터는 프라미스 contentAsBlob 반환됩니다.

https://learn.microsoft.com/rest/api/storageservices/get-file 참조

downloadToBuffer(Buffer, number, number, FileDownloadToBufferOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

버퍼와 병렬로 Azure 파일을 다운로드합니다. 오프셋 및 개수는 선택 사항이며, 전체 파일을 다운로드하려면 둘 다 0을 전달합니다.

경고: 버퍼는 Node.js/V8의 제한으로 인해 32비트 시스템에서 최대 1GB 또는 64비트 시스템에서 약 2GB의 파일만 지원할 수 있습니다. 이 크기보다 큰 파일의 경우 downloadToFile 것이 좋습니다.

downloadToBuffer(number, number, FileDownloadToBufferOptions)

NODE.JS 런타임에서만 사용 가능

버퍼와 병렬로 Azure 파일을 다운로드합니다. 오프셋 및 개수는 선택 사항이며, 전체 파일을 다운로드하려면 둘 다 0을 전달합니다.

경고: 버퍼는 Node.js/V8의 제한으로 인해 32비트 시스템에서 최대 1GB 또는 64비트 시스템에서 약 2GB의 파일만 지원할 수 있습니다. 이 크기보다 큰 파일의 경우 downloadToFile 것이 좋습니다.

downloadToFile(string, number, number, FileDownloadOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

로컬 파일에 Azure Blob을 다운로드합니다. 지정된 파일 경로가 이미 종료되면 실패합니다. 오프셋 및 개수는 선택 사항이며, 각각 0과 정의되지 않은 값을 전달하여 전체 Blob을 다운로드합니다.

exists(FileExistsOptions)

지정된 파일이 있으면 true를 반환합니다. false이면 false입니다.

참고: 다른 클라이언트 또는 애플리케이션에서 기존 파일을 삭제할 수 있기 때문에 이 함수를 주의해서 사용합니다. 그 반대로 이 함수가 완료된 후 다른 클라이언트 또는 애플리케이션에서 새 파일을 추가할 수 있습니다.

forceCloseAllHandles(FileForceCloseHandlesOptions)

파일에 대한 모든 핸들을 강제로 닫습니다.

https://learn.microsoft.com/rest/api/storageservices/force-close-handles 참조

forceCloseHandle(string, FileForceCloseHandlesOptions)

파일에 대한 특정 핸들을 강제로 닫습니다.

https://learn.microsoft.com/rest/api/storageservices/force-close-handles 참조

generateSasStringToSign(FileGenerateSasUrlOptions)

공유 키 자격 증명을 사용하여 생성된 클라이언트에만 사용할 수 있습니다.

전달된 클라이언트 속성 및 매개 변수를 기반으로 SAS(서비스 공유 액세스 서명) URI에 서명하는 문자열을 생성합니다. SAS는 클라이언트의 공유 키 자격 증명으로 서명됩니다.

https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas 참조

generateSasUrl(FileGenerateSasUrlOptions)

공유 키 자격 증명을 사용하여 생성된 클라이언트에만 사용할 수 있습니다.

전달된 클라이언트 속성 및 매개 변수를 기반으로 SAS(서비스 공유 액세스 서명) URI를 생성합니다. SAS는 클라이언트의 공유 키 자격 증명으로 서명됩니다.

https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas 참조

getProperties(FileGetPropertiesOptions)

파일에 대한 모든 사용자 정의 메타데이터, 표준 HTTP 속성 및 시스템 속성을 반환합니다. 파일의 내용을 반환하지 않습니다.

https://learn.microsoft.com/rest/api/storageservices/get-file-properties 참조

getRangeList(FileGetRangeListOptions)

파일의 유효한 범위 목록을 반환합니다.

getRangeListDiff(string, FileGetRangeListOptions)

이전 공유 스냅샷과 이 파일 간에 다른 범위 목록을 반환합니다.

getShareLeaseClient(string)

파일에서 임대를 관리하는 ShareLeaseClient 가져옵니다.

getSymbolicLink(FileGetSymbolicLinkOptions)

NFS만 해당됩니다. 심볼 링크의 내용을 가져옵니다.

listHandles(FileListHandlesOptions)

모든 핸들을 나열하는 비동기 반복기를 반환합니다. 지정된 계정 아래에 있습니다.

.byPage()는 비동기 반복 반복기를 반환하여 페이지의 핸들을 나열합니다.

rename(string, FileRenameOptions)

파일 이름을 바꿉니다. 이 API는 동일한 공유의 파일 이름 바꾸기만 지원합니다.

resize(number, FileResizeOptions)

파일 크기를 조정합니다.

https://learn.microsoft.com/rest/api/storageservices/set-file-properties 참조

setHttpHeaders(FileHttpHeaders, FileSetHttpHeadersOptions)

파일에서 HTTP 헤더를 설정합니다.

옵션이 제공되지 않거나 옵션에서 파일 HTTP 헤더에 대한 값이 제공되지 않은 경우 값이 없는 이러한 파일 HTTP 헤더는 지워지게 됩니다.

https://learn.microsoft.com/rest/api/storageservices/set-file-properties 참조

setMetadata(Metadata, FileSetMetadataOptions)

지정된 파일에 대한 사용자 정의 메타데이터를 업데이트합니다.

옵션 매개 변수에 정의된 메타데이터가 없으면 파일 메타데이터가 제거됩니다.

https://learn.microsoft.com/rest/api/storageservices/set-file-metadata 참조

setProperties(FileProperties)

파일의 속성을 설정합니다.

https://learn.microsoft.com/rest/api/storageservices/set-file-properties 참조

startCopyFromURL(string, FileStartCopyOptions)

스토리지 계정 내의 대상 파일에 Blob 또는 파일을 복사합니다.

uploadData(Blob | ArrayBuffer | ArrayBufferView | Buffer, FileParallelUploadOptions)

새 Azure 파일을 만들거나 기존 Azure 파일을 대체한 다음 버퍼(Node)/Blob/ArrayBuffer/ArrayBufferView를 업로드합니다.

uploadFile(string, FileParallelUploadOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

새 Azure 파일을 만들거나 기존 Azure 파일을 바꾼 다음 로컬 파일을 업로드합니다.

uploadRange(RequestBodyType, number, number, FileUploadRangeOptions)

파일에 바이트 범위를 업로드합니다. 이 작업은 기존 파일에서만 호출할 수 있습니다. 파일의 크기, 속성 또는 메타데이터는 변경되지 않습니다. 범위의 시작 및 개수를 모두 지정해야 합니다. 범위의 크기는 최대 4MB입니다.

uploadRangeFromURL(string, number, number, number, FileUploadRangeFromURLOptions)

다른 파일의 URL에서 콘텐츠를 읽는 파일에 바이트 범위를 업로드합니다. 범위의 크기는 최대 4MB입니다.

uploadResetableStream((offset: number, count?: number) => ReadableStream, number, FileParallelUploadOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

Node.js 읽기 가능한 스트림 팩터리를 수락하고 블록 단위로 Azure File에 업로드합니다. 읽기 가능한 스트림 팩터리는 정의된 오프셋에서 시작하는 Node.js 읽기 가능한 스트림을 반환해야 합니다. 오프셋은 업로드할 Azure 파일의 오프셋입니다.

uploadSeekableBlob((offset: number, size: number) => Blob, number, FileParallelUploadOptions)

브라우저에서만 사용할 수 있습니다.

브라우저 Blob 개체를 Azure 파일에 업로드합니다. 제공된 오프셋 및 크기가 있는 Blob 개체를 반환해야 하는 데이터 원본으로 BlobFactory가 필요합니다.

uploadStream(Readable, number, number, number, FileUploadStreamOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

새 Azure 파일을 만들거나 기존 Azure 파일을 바꾼 다음 Node.js 읽기 가능한 스트림을 업로드합니다. 이 메서드는 Azure 파일을 만든 다음 청크로 청크 업로드를 시작합니다. 청크의 크기는 bufferSize 매개 변수에 의해 정의됩니다. 스트림의 잠재적 크기가 파일 크기를 초과하지 않는지 확인하세요.

성능 향상 팁:

  • 입력 스트림 highWaterMark는 Buffer.concat() 작업을 방지하는 bufferSize 매개 변수를 사용하여 동일한 값을 설정하는 것이 좋습니다.
withShareSnapshot(string)

원본과 동일하지만 지정된 공유 스냅샷 타임스탬프를 사용하여 새 ShareFileClient 개체를 만듭니다. ""를 입력하면 스냅샷이 제거되고 기본 ShareFileClient에 URL이 반환됩니다.

생성자 세부 정보

ShareFileClient(string, Credential | TokenCredential, ShareClientOptions)

ShareFileClient의 인스턴스를 만듭니다.

new ShareFileClient(url: string, credential?: Credential | TokenCredential, options?: ShareClientOptions)

매개 변수

url

string

Azure Storage 파일을 가리키는 URL 문자열(예: "https://myaccount.file.core.windows.net/myshare/mydirectory/file")입니다. AnonymousCredential을 사용하는 경우 SAS를 추가할 수 있습니다(예: "https://myaccount.file.core.windows.net/myshare/mydirectory/file?sasString"). 이 메서드는 인코딩된 URL 또는 파일을 가리키는 인코딩하지 않은 URL을 허용합니다. 인코딩된 URL 문자열은 두 번 이스케이프되지 않으며 URL 경로의 특수 문자만 이스케이프됩니다. 그러나 파일 또는 디렉터리 이름에 %포함된 경우 URL에서 파일 또는 디렉터리 이름을 인코딩해야 합니다. "myfile%"이라는 파일과 같이 URL은 "https://myaccount.file.core.windows.net/myshare/mydirectory/myfile%25"이어야 합니다.

credential

Credential | TokenCredential

StorageSharedKeyCredential 또는 TokenCredential과 같이 지정하지 않으면 AnonymousCredential이 사용됩니다.

options
ShareClientOptions

Optional. HTTP 파이프라인을 구성하는 옵션입니다.

ShareFileClient(string, Pipeline, ShareClientConfig)

ShareFileClient의 인스턴스를 만듭니다.

new ShareFileClient(url: string, pipeline: Pipeline, options?: ShareClientConfig)

매개 변수

url

string

Azure Storage 파일을 가리키는 URL 문자열(예: "https://myaccount.file.core.windows.net/myshare/mydirectory/file")입니다. AnonymousCredential을 사용하는 경우 SAS를 추가할 수 있습니다(예: "https://myaccount.file.core.windows.net/myshare/mydirectory/file?sasString"). 이 메서드는 인코딩된 URL 또는 파일을 가리키는 인코딩하지 않은 URL을 허용합니다. 인코딩된 URL 문자열은 두 번 이스케이프되지 않으며 URL 경로의 특수 문자만 이스케이프됩니다. 그러나 파일 또는 디렉터리 이름에 %포함된 경우 URL에서 파일 또는 디렉터리 이름을 인코딩해야 합니다. "myfile%"이라는 파일과 같이 URL은 "https://myaccount.file.core.windows.net/myshare/mydirectory/myfile%25"이어야 합니다.

pipeline
Pipeline

newPipeline()을 호출하여 기본 파이프라인을 만들거나 사용자 지정된 파이프라인을 제공합니다.

속성 세부 정보

name

파일의 이름입니다.

string name

속성 값

string

path

파일의 전체 경로

string path

속성 값

string

shareName

이 파일 클라이언트에 해당하는 공유 이름

string shareName

속성 값

string

상속된 속성 세부 정보

accountName

accountName: string

속성 값

string

StorageClient.accountName에서 상속된

url

URL 문자열 값입니다.

url: string

속성 값

string

StorageClient.url에서 상속된

메서드 세부 정보

abortCopyFromURL(string, FileAbortCopyFromURLOptions)

보류 중인 파일 복사 작업을 중단하고 길이가 0인 대상 파일과 전체 메타데이터를 남깁니다.

https://learn.microsoft.com/rest/api/storageservices/abort-copy-file 참조

function abortCopyFromURL(copyId: string, options?: FileAbortCopyFromURLOptions): Promise<FileAbortCopyResponse>

매개 변수

copyId

string

중단할 파일 복사 작업의 ID입니다.

options
FileAbortCopyFromURLOptions

URL에서 복사를 중단하는 파일 옵션입니다.

반환

clearRange(number, number, FileClearRangeOptions)

지정된 범위를 지우고 해당 범위에 대한 스토리지에 사용되는 공간을 해제합니다.

function clearRange(offset: number, contentLength: number, options?: FileClearRangeOptions): Promise<FileUploadRangeResponse>

매개 변수

offset

number

contentLength

number

options
FileClearRangeOptions

파일 지우기 범위 작업에 대한 옵션입니다.

반환

create(number, FileCreateOptions)

새 파일을 만들거나 파일을 대체합니다. 콘텐츠가 없는 파일만 초기화합니다.

https://learn.microsoft.com/rest/api/storageservices/create-file 참조

function create(size: number, options?: FileCreateOptions): Promise<FileCreateResponse>

매개 변수

size

number

파일의 최대 크기(바이트)를 최대 4TB로 지정합니다.

options
FileCreateOptions

파일 만들기 작업에 대한 옵션입니다.

반환

파일 만들기 작업에 대한 응답 데이터입니다.

사용 예:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

const content = "Hello World!";
const fileName = `newdirectory${+new Date()}`;
const fileClient = directoryClient.getFileClient(fileName);
await fileClient.create(content.length);
console.log(`Create file ${fileName} successfully`);

// Upload file range
await fileClient.uploadRange(content, 0, content.length);
console.log(`Upload file range "${content}" to ${fileName} successfully`);

NFS만 해당됩니다. 경로로 지정된 파일 파일에 대한 하드 링크를 만듭니다.

function createHardLink(targetFile: string, options?: FileCreateHardLinkOptions): Promise<FileCreateHardLinkResponse>

매개 변수

targetFile

string

공유를 포함하지 않고 하드 링크를 만들 파일의 경로입니다. 예: "targetDirectory/targetSubDirectory/.../targetFile"

options
FileCreateHardLinkOptions

하드 링크 작업을 만드는 옵션입니다.

반환

NFS만 해당됩니다. 기호 링크를 만듭니다.

function createSymbolicLink(linkText: string, options?: FileCreateSymbolicLinkOptions): Promise<FileCreateSymbolicLinkResponse>

매개 변수

linkText

string

원본 파일의 경로, 심볼릭 링크가 가리키고 있습니다. 경로는 확인되지 않고 그대로 저장되는 문자열 유형입니다. 경로는 절대 경로일 수도 있고 기호 링크 파일에 저장된 내용에 따라 상대 경로일 수도 있습니다.

options
FileCreateSymbolicLinkOptions

하드 링크 작업을 만드는 옵션입니다.

반환

delete(FileDeleteOptions)

스토리지 계정에서 파일을 제거합니다. 파일이 성공적으로 삭제되면 스토리지 계정의 인덱스에서 즉시 제거되고 클라이언트가 더 이상 액세스할 수 없습니다. 파일의 데이터는 나중에 가비지 수집 중에 서비스에서 제거됩니다.

SMB 클라이언트에서 파일이 열려 있으면 상태 코드 409(충돌) 및 오류 코드 SharingViolation으로 파일 삭제가 실패합니다.

공유의 읽기 전용 복사본인 공유 스냅샷에서는 파일 삭제가 지원되지 않습니다. 공유 스냅샷에서 이 작업을 수행하려고 하면 400(InvalidQueryParameterValue)으로 실패합니다.

https://learn.microsoft.com/rest/api/storageservices/delete-file2 참조

function delete(options?: FileDeleteOptions): Promise<FileDeleteResponse>

매개 변수

options
FileDeleteOptions

파일 삭제 작업에 대한 옵션입니다.

반환

파일 삭제 작업에 대한 응답 데이터입니다.

deleteIfExists(FileDeleteOptions)

파일이 있는 경우 스토리지 계정에서 파일을 제거합니다. 파일이 성공적으로 삭제되면 스토리지 계정의 인덱스에서 즉시 제거되고 클라이언트가 더 이상 액세스할 수 없습니다. 파일의 데이터는 나중에 가비지 수집 중에 서비스에서 제거됩니다.

SMB 클라이언트에서 파일이 열려 있으면 상태 코드 409(충돌) 및 오류 코드 SharingViolation으로 파일 삭제가 실패합니다.

공유의 읽기 전용 복사본인 공유 스냅샷에서는 파일 삭제가 지원되지 않습니다. 공유 스냅샷에서 이 작업을 수행하려고 하면 400(InvalidQueryParameterValue)으로 실패합니다.

https://learn.microsoft.com/rest/api/storageservices/delete-file2 참조

function deleteIfExists(options?: FileDeleteOptions): Promise<FileDeleteIfExistsResponse>

매개 변수

반환

download(number, number, FileDownloadOptions)

메타데이터 및 속성을 포함하여 시스템에서 파일을 읽거나 다운로드합니다.

  • Node.js데이터는 읽기 가능한 스트림 readableStreamBody 반환됩니다.
  • 브라우저에서 데이터는 프라미스 contentAsBlob 반환됩니다.

https://learn.microsoft.com/rest/api/storageservices/get-file 참조

function download(offset?: number, count?: number, options?: FileDownloadOptions): Promise<FileDownloadResponseModel>

매개 변수

offset

number

다운로드할 파일의 위치(0보다 크거나 같음)

count

number

다운로드할 데이터의 양(0보다 큼)입니다. 정의되지 않은 경우 끝까지 다운로드됩니다.

options
FileDownloadOptions

파일 다운로드 작업에 대한 옵션입니다.

반환

파일 다운로드 작업에 대한 응답 데이터입니다.

예제 사용량(Node.js):

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const fileName = "<file name>";
const fileClient = serviceClient
  .getShareClient(shareName)
  .rootDirectoryClient.getFileClient(fileName);

// Get file content from position 0 to the end
// In Node.js, get downloaded data by accessing downloadFileResponse.readableStreamBody
const downloadFileResponse = await fileClient.download();
if (downloadFileResponse.readableStreamBody) {
  const buffer = await streamToBuffer(downloadFileResponse.readableStreamBody);
  console.log(`Downloaded file content: ${buffer.toString()}`);
}

// [Node.js only] A helper method used to read a Node.js readable stream into a Buffer
async function streamToBuffer(readableStream: NodeJS.ReadableStream): Promise<Buffer> {
  return new Promise((resolve, reject) => {
    const chunks: Buffer[] = [];
    readableStream.on("data", (data) => {
      chunks.push(data instanceof Buffer ? data : Buffer.from(data));
    });
    readableStream.on("end", () => {
      resolve(Buffer.concat(chunks));
    });
    readableStream.on("error", reject);
  });
}

사용 예(브라우저):

import { ShareServiceClient } from "@azure/storage-file-share";

const account = "<account name>";
const sas = "<service Shared Access Signature Token>";

const serviceClient = new ShareServiceClient(`https://${account}.file.core.windows.net?${sas}`);

const shareName = "<share name>";
const fileName = "<file name>";
const fileClient = serviceClient
  .getShareClient(shareName)
  .rootDirectoryClient.getFileClient(fileName);

// Get file content from position 0 to the end
// In browsers, get downloaded data by accessing downloadFileResponse.blobBody
const downloadFileResponse = await fileClient.download(0);
if (downloadFileResponse.blobBody) {
  console.log(`Downloaded file content: ${(await downloadFileResponse.blobBody).text()}`);
}

downloadToBuffer(Buffer, number, number, FileDownloadToBufferOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

버퍼와 병렬로 Azure 파일을 다운로드합니다. 오프셋 및 개수는 선택 사항이며, 전체 파일을 다운로드하려면 둘 다 0을 전달합니다.

경고: 버퍼는 Node.js/V8의 제한으로 인해 32비트 시스템에서 최대 1GB 또는 64비트 시스템에서 약 2GB의 파일만 지원할 수 있습니다. 이 크기보다 큰 파일의 경우 downloadToFile 것이 좋습니다.

function downloadToBuffer(buffer: Buffer, offset?: number, count?: number, options?: FileDownloadToBufferOptions): Promise<Buffer>

매개 변수

buffer

Buffer

채울 버퍼, 개수보다 큰 길이가 있어야 합니다.

offset

number

다운로드할 Azure 파일의 위치

count

number

다운로드할 데이터의 양입니다. 정의되지 않은 상태로 전달할 때 끝까지 다운로드됩니다.

반환

Promise<Buffer>

downloadToBuffer(number, number, FileDownloadToBufferOptions)

NODE.JS 런타임에서만 사용 가능

버퍼와 병렬로 Azure 파일을 다운로드합니다. 오프셋 및 개수는 선택 사항이며, 전체 파일을 다운로드하려면 둘 다 0을 전달합니다.

경고: 버퍼는 Node.js/V8의 제한으로 인해 32비트 시스템에서 최대 1GB 또는 64비트 시스템에서 약 2GB의 파일만 지원할 수 있습니다. 이 크기보다 큰 파일의 경우 downloadToFile 것이 좋습니다.

function downloadToBuffer(offset?: number, count?: number, options?: FileDownloadToBufferOptions): Promise<Buffer>

매개 변수

offset

number

다운로드할 Azure 파일의 위치

count

number

다운로드할 데이터의 양입니다. 정의되지 않은 상태로 전달할 때 끝까지 다운로드됩니다.

반환

Promise<Buffer>

downloadToFile(string, number, number, FileDownloadOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

로컬 파일에 Azure Blob을 다운로드합니다. 지정된 파일 경로가 이미 종료되면 실패합니다. 오프셋 및 개수는 선택 사항이며, 각각 0과 정의되지 않은 값을 전달하여 전체 Blob을 다운로드합니다.

function downloadToFile(filePath: string, offset?: number, count?: number, options?: FileDownloadOptions): Promise<FileDownloadResponseModel>

매개 변수

filePath

string

offset

number

다운로드할 블록 Blob의 위치입니다.

count

number

다운로드할 데이터의 양입니다. 정의되지 않은 상태로 전달할 때 끝까지 다운로드됩니다.

options
FileDownloadOptions

Blob 다운로드 옵션입니다.

반환

Blob 다운로드 작업에 대한 응답 데이터이지만 읽기 가능한StreamBody는 해당 콘텐츠가 지정된 경로의 로컬 파일에 이미 읽고 쓰여졌기 때문에 정의되지 않은 상태로 설정됩니다.

exists(FileExistsOptions)

지정된 파일이 있으면 true를 반환합니다. false이면 false입니다.

참고: 다른 클라이언트 또는 애플리케이션에서 기존 파일을 삭제할 수 있기 때문에 이 함수를 주의해서 사용합니다. 그 반대로 이 함수가 완료된 후 다른 클라이언트 또는 애플리케이션에서 새 파일을 추가할 수 있습니다.

function exists(options?: FileExistsOptions): Promise<boolean>

매개 변수

options
FileExistsOptions

옵션에서 Exists 연산을 수행할 수 있습니다.

반환

Promise<boolean>

forceCloseAllHandles(FileForceCloseHandlesOptions)

파일에 대한 모든 핸들을 강제로 닫습니다.

https://learn.microsoft.com/rest/api/storageservices/force-close-handles 참조

function forceCloseAllHandles(options?: FileForceCloseHandlesOptions): Promise<CloseHandlesInfo>

매개 변수

options
FileForceCloseHandlesOptions

핸들 닫기 작업을 강제 적용하는 옵션입니다.

반환

Promise<CloseHandlesInfo>

forceCloseHandle(string, FileForceCloseHandlesOptions)

파일에 대한 특정 핸들을 강제로 닫습니다.

https://learn.microsoft.com/rest/api/storageservices/force-close-handles 참조

function forceCloseHandle(handleId: string, options?: FileForceCloseHandlesOptions): Promise<FileForceCloseHandlesResponse>

매개 변수

handleId

string

특정 핸들 ID는 별표 "*"일 수 없습니다. forceCloseAllHandles()를 사용하여 모든 핸들을 닫습니다.

반환

generateSasStringToSign(FileGenerateSasUrlOptions)

공유 키 자격 증명을 사용하여 생성된 클라이언트에만 사용할 수 있습니다.

전달된 클라이언트 속성 및 매개 변수를 기반으로 SAS(서비스 공유 액세스 서명) URI에 서명하는 문자열을 생성합니다. SAS는 클라이언트의 공유 키 자격 증명으로 서명됩니다.

https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas 참조

function generateSasStringToSign(options: FileGenerateSasUrlOptions): string

매개 변수

options
FileGenerateSasUrlOptions

선택적 매개 변수입니다.

반환

string

이 클라이언트가 나타내는 리소스에 대한 URI로 구성된 SAS URI와 생성된 SAS 토큰이 뒤따릅니다.

generateSasUrl(FileGenerateSasUrlOptions)

공유 키 자격 증명을 사용하여 생성된 클라이언트에만 사용할 수 있습니다.

전달된 클라이언트 속성 및 매개 변수를 기반으로 SAS(서비스 공유 액세스 서명) URI를 생성합니다. SAS는 클라이언트의 공유 키 자격 증명으로 서명됩니다.

https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas 참조

function generateSasUrl(options: FileGenerateSasUrlOptions): string

매개 변수

options
FileGenerateSasUrlOptions

선택적 매개 변수입니다.

반환

string

이 클라이언트가 나타내는 리소스에 대한 URI로 구성된 SAS URI와 생성된 SAS 토큰이 뒤따릅니다.

getProperties(FileGetPropertiesOptions)

파일에 대한 모든 사용자 정의 메타데이터, 표준 HTTP 속성 및 시스템 속성을 반환합니다. 파일의 내용을 반환하지 않습니다.

https://learn.microsoft.com/rest/api/storageservices/get-file-properties 참조

function getProperties(options?: FileGetPropertiesOptions): Promise<FileGetPropertiesResponse>

매개 변수

options
FileGetPropertiesOptions

파일 가져오기 속성 작업에 대한 옵션입니다.

반환

파일 가져오기 속성 작업에 대한 응답 데이터입니다.

getRangeList(FileGetRangeListOptions)

파일의 유효한 범위 목록을 반환합니다.

function getRangeList(options?: FileGetRangeListOptions): Promise<FileGetRangeListResponse>

매개 변수

options
FileGetRangeListOptions

파일 범위 목록 가져오기 작업에 대한 옵션입니다.

반환

getRangeListDiff(string, FileGetRangeListOptions)

이전 공유 스냅샷과 이 파일 간에 다른 범위 목록을 반환합니다.

function getRangeListDiff(prevShareSnapshot: string, options?: FileGetRangeListOptions): Promise<FileGetRangeListDiffResponse>

매개 변수

prevShareSnapshot

string

이전 스냅샷 매개 변수는 비교할 이전 공유 스냅샷을 지정하는 불투명 DateTime 값입니다.

반환

getShareLeaseClient(string)

파일에서 임대를 관리하는 ShareLeaseClient 가져옵니다.

function getShareLeaseClient(proposeLeaseId?: string): ShareLeaseClient

매개 변수

proposeLeaseId

string

처음 제안된 임대 ID입니다.

반환

파일에서 임대를 관리하기 위한 새 ShareLeaseClient 개체입니다.

NFS만 해당됩니다. 심볼 링크의 내용을 가져옵니다.

function getSymbolicLink(options?: FileGetSymbolicLinkOptions): Promise<FileGetSymbolicLinkResponse>

매개 변수

options
FileGetSymbolicLinkOptions

심볼릭 링크 작업을 가져오는 옵션입니다.

반환

listHandles(FileListHandlesOptions)

모든 핸들을 나열하는 비동기 반복기를 반환합니다. 지정된 계정 아래에 있습니다.

.byPage()는 비동기 반복 반복기를 반환하여 페이지의 핸들을 나열합니다.

function listHandles(options?: FileListHandlesOptions): PagedAsyncIterableIterator<HandleItem, FileListHandlesResponse, PageSettings>

매개 변수

options
FileListHandlesOptions

핸들 작업을 나열하는 옵션입니다.

페이징을 지원하는 asyncIterableIterator입니다.

반환

rename(string, FileRenameOptions)

파일 이름을 바꿉니다. 이 API는 동일한 공유의 파일 이름 바꾸기만 지원합니다.

function rename(destinationPath: string, options?: FileRenameOptions): Promise<{ destinationFileClient: ShareFileClient, fileRenameResponse: FileRenameResponse }>

매개 변수

destinationPath

string

이름을 바꿀 대상 경로를 지정합니다. 경로를 URL로 인코딩하여 대상을 지정합니다.

options
FileRenameOptions

이름 바꾸기 작업에 대한 옵션입니다.

반환

Promise<{ destinationFileClient: ShareFileClient, fileRenameResponse: FileRenameResponse }>

파일 이름 바꾸기 작업에 대한 응답 데이터입니다.

사용 예:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const fileName = "<file name>";
const destinationPath = "<destination path>";
const fileClient = serviceClient
  .getShareClient(shareName)
  .getDirectoryClient(directoryName)
  .getFileClient(fileName);

await fileClient.rename(destinationPath);

resize(number, FileResizeOptions)

파일 크기를 조정합니다.

https://learn.microsoft.com/rest/api/storageservices/set-file-properties 참조

function resize(length: number, options?: FileResizeOptions): Promise<FileSetHTTPHeadersResponse>

매개 변수

length

number

파일 크기를 지정된 크기(바이트)로 조정합니다. 지정된 바이트 값이 파일의 현재 크기보다 작으면 지정된 바이트 값 위의 모든 범위가 지워집니다.

options
FileResizeOptions

파일 크기 조정 작업에 대한 옵션입니다.

반환

파일 집합 HTTP 헤더 작업에 대한 응답 데이터입니다.

setHttpHeaders(FileHttpHeaders, FileSetHttpHeadersOptions)

파일에서 HTTP 헤더를 설정합니다.

옵션이 제공되지 않거나 옵션에서 파일 HTTP 헤더에 대한 값이 제공되지 않은 경우 값이 없는 이러한 파일 HTTP 헤더는 지워지게 됩니다.

https://learn.microsoft.com/rest/api/storageservices/set-file-properties 참조

function setHttpHeaders(fileHttpHeaders?: FileHttpHeaders, options?: FileSetHttpHeadersOptions): Promise<FileSetHTTPHeadersResponse>

매개 변수

fileHttpHeaders
FileHttpHeaders
options
FileSetHttpHeadersOptions

HTTP 헤더 파일 설정 작업에 대한 옵션입니다.

반환

파일 집합 HTTP 헤더 작업에 대한 응답 데이터입니다.

setMetadata(Metadata, FileSetMetadataOptions)

지정된 파일에 대한 사용자 정의 메타데이터를 업데이트합니다.

옵션 매개 변수에 정의된 메타데이터가 없으면 파일 메타데이터가 제거됩니다.

https://learn.microsoft.com/rest/api/storageservices/set-file-metadata 참조

function setMetadata(metadata?: Metadata, options?: FileSetMetadataOptions): Promise<FileSetMetadataResponse>

매개 변수

metadata
Metadata

메타데이터가 제공되지 않으면 모든 기존 디렉터리 메타데이터가 제거됩니다.

options
FileSetMetadataOptions

파일 집합 메타데이터 작업에 대한 옵션입니다.

반환

파일 집합 메타데이터 작업에 대한 응답 데이터입니다.

setProperties(FileProperties)

파일의 속성을 설정합니다.

https://learn.microsoft.com/rest/api/storageservices/set-file-properties 참조

function setProperties(properties?: FileProperties): Promise<SetPropertiesResponse>

매개 변수

properties
FileProperties

파일 속성. 파일 HTTP 헤더(예: Content-Type)의 경우 값이 제공되지 않으면 기존 HTTP 헤더가 제거됩니다. 다른 파일 속성(예: fileAttributes)의 경우 값이 제공되지 않으면 기존 값이 유지됩니다.

반환

startCopyFromURL(string, FileStartCopyOptions)

스토리지 계정 내의 대상 파일에 Blob 또는 파일을 복사합니다.

function startCopyFromURL(copySource: string, options?: FileStartCopyOptions): Promise<FileStartCopyResponse>

매개 변수

copySource

string

원본 파일 또는 Blob의 URL을 최대 2KB 길이로 지정합니다. 동일한 스토리지 계정 내의 다른 파일에 파일을 복사하려면 공유 키를 사용하여 원본 파일을 인증할 수 있습니다. 다른 스토리지 계정에서 파일을 복사하거나 동일한 스토리지 계정 또는 다른 스토리지 계정에서 Blob을 복사하는 경우 공유 액세스 서명을 사용하여 원본 파일 또는 Blob을 인증해야 합니다. 원본이 공용 Blob인 경우 복사 작업을 수행하기 위해 인증이 필요하지 않습니다. 공유 스냅샷의 파일을 복사 원본으로 지정할 수도 있습니다.

options
FileStartCopyOptions

파일 복사 시작 작업에 대한 옵션입니다.

반환

uploadData(Blob | ArrayBuffer | ArrayBufferView | Buffer, FileParallelUploadOptions)

새 Azure 파일을 만들거나 기존 Azure 파일을 대체한 다음 버퍼(Node)/Blob/ArrayBuffer/ArrayBufferView를 업로드합니다.

function uploadData(data: Blob | ArrayBuffer | ArrayBufferView | Buffer, options?: FileParallelUploadOptions): Promise<void>

매개 변수

data

Blob | ArrayBuffer | ArrayBufferView | Buffer

Buffer(Node), Blob, ArrayBuffer 또는 ArrayBufferView

반환

Promise<void>

uploadFile(string, FileParallelUploadOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

새 Azure 파일을 만들거나 기존 Azure 파일을 바꾼 다음 로컬 파일을 업로드합니다.

function uploadFile(filePath: string, options?: FileParallelUploadOptions): Promise<void>

매개 변수

filePath

string

로컬 파일의 전체 경로

반환

Promise<void>

uploadRange(RequestBodyType, number, number, FileUploadRangeOptions)

파일에 바이트 범위를 업로드합니다. 이 작업은 기존 파일에서만 호출할 수 있습니다. 파일의 크기, 속성 또는 메타데이터는 변경되지 않습니다. 범위의 시작 및 개수를 모두 지정해야 합니다. 범위의 크기는 최대 4MB입니다.

function uploadRange(body: RequestBodyType, offset: number, contentLength: number, options?: FileUploadRangeOptions): Promise<FileUploadRangeResponse>

매개 변수

body
HttpRequestBody

Blob, string, ArrayBuffer, ArrayBufferView 또는 오프셋이 데이터 원본에서 시작하는 새 읽기 가능한 스트림을 반환하는 함수입니다.

offset

number

업로드할 대상 Azure 파일의 오프셋 위치입니다.

contentLength

number

본문 길이(바이트)입니다. Buffer.byteLength()를 사용하여 Base64/Hex로 인코딩된 문자가 아닌 문자열의 본문 길이를 계산합니다.

options
FileUploadRangeOptions

파일 업로드 범위 작업에 대한 옵션입니다.

반환

파일 업로드 범위 작업에 대한 응답 데이터입니다.

사용 예:

import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";

const account = "<account>";
const accountKey = "<accountkey>";

const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
  `https://${account}.file.core.windows.net`,
  credential,
);

const shareName = "<share name>";
const directoryName = "<directory name>";
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryName);

const content = "Hello World!";
const fileName = `newdirectory${+new Date()}`;
const fileClient = directoryClient.getFileClient(fileName);
await fileClient.create(content.length);
console.log(`Create file ${fileName} successfully`);

// Upload file range
await fileClient.uploadRange(content, 0, content.length);
console.log(`Upload file range "${content}" to ${fileName} successfully`);

uploadRangeFromURL(string, number, number, number, FileUploadRangeFromURLOptions)

다른 파일의 URL에서 콘텐츠를 읽는 파일에 바이트 범위를 업로드합니다. 범위의 크기는 최대 4MB입니다.

function uploadRangeFromURL(sourceURL: string, sourceOffset: number, destOffset: number, count: number, options?: FileUploadRangeFromURLOptions): Promise<FileUploadRangeFromURLResponse>

매개 변수

sourceURL

string

복사 원본에 대한 URL을 지정합니다. SAS(공유 액세스 서명)는 인증에 필요할 수 있습니다.

sourceOffset

number

복사할 원본 오프셋입니다. 소스 파일의 시작 부분에서 복사하려면 0을 전달합니다.

destOffset

number

대상 파일의 오프셋입니다.

count

number

원본 파일에서 업로드할 바이트 수입니다.

options
FileUploadRangeFromURLOptions

파일 구성 옵션 - URL 작업에서 범위 업로드

반환

uploadResetableStream((offset: number, count?: number) => ReadableStream, number, FileParallelUploadOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

Node.js 읽기 가능한 스트림 팩터리를 수락하고 블록 단위로 Azure File에 업로드합니다. 읽기 가능한 스트림 팩터리는 정의된 오프셋에서 시작하는 Node.js 읽기 가능한 스트림을 반환해야 합니다. 오프셋은 업로드할 Azure 파일의 오프셋입니다.

function uploadResetableStream(streamFactory: (offset: number, count?: number) => ReadableStream, size: number, options?: FileParallelUploadOptions): Promise<void>

매개 변수

streamFactory

(offset: number, count?: number) => ReadableStream

정의된 오프셋에서 시작하는 Node.js 읽기 가능한 스트림을 반환합니다.

size

number

Azure 파일의 크기

반환

Promise<void>

uploadSeekableBlob((offset: number, size: number) => Blob, number, FileParallelUploadOptions)

브라우저에서만 사용할 수 있습니다.

브라우저 Blob 개체를 Azure 파일에 업로드합니다. 제공된 오프셋 및 크기가 있는 Blob 개체를 반환해야 하는 데이터 원본으로 BlobFactory가 필요합니다.

function uploadSeekableBlob(blobFactory: (offset: number, size: number) => Blob, size: number, options?: FileParallelUploadOptions): Promise<void>

매개 변수

blobFactory

(offset: number, size: number) => Blob

size

number

반환

Promise<void>

uploadStream(Readable, number, number, number, FileUploadStreamOptions)

NODE.JS 런타임에서만 사용할 수 있습니다.

새 Azure 파일을 만들거나 기존 Azure 파일을 바꾼 다음 Node.js 읽기 가능한 스트림을 업로드합니다. 이 메서드는 Azure 파일을 만든 다음 청크로 청크 업로드를 시작합니다. 청크의 크기는 bufferSize 매개 변수에 의해 정의됩니다. 스트림의 잠재적 크기가 파일 크기를 초과하지 않는지 확인하세요.

성능 향상 팁:

  • 입력 스트림 highWaterMark는 Buffer.concat() 작업을 방지하는 bufferSize 매개 변수를 사용하여 동일한 값을 설정하는 것이 좋습니다.
function uploadStream(stream: Readable, size: number, bufferSize: number, maxBuffers: number, options?: FileUploadStreamOptions): Promise<void>

매개 변수

stream

Readable

Node.js 읽기 가능한 스트림입니다. 파일 크기보다 작거나 같아야 합니다.

size

number

만들 파일의 크기입니다. 허용되는 최대 크기는 4TB입니다. 이 값이 스트림 크기보다 크면 파일 꼬리에 빈 바이트가 있습니다.

bufferSize

number

업로드된 파일 중에 할당된 모든 버퍼의 크기(바이트)도 청크/범위 크기입니다. 크기는 0보다 크고 4 * 1024 * 1024 (4MB)보다 작거나 같아야 합니다.

maxBuffers

number

최대 버퍼는 업로드하는 동안 할당되며 최대 업로드 동시성과 양수 상관 관계입니다.

반환

Promise<void>

withShareSnapshot(string)

원본과 동일하지만 지정된 공유 스냅샷 타임스탬프를 사용하여 새 ShareFileClient 개체를 만듭니다. ""를 입력하면 스냅샷이 제거되고 기본 ShareFileClient에 URL이 반환됩니다.

function withShareSnapshot(shareSnapshot: string): ShareFileClient

매개 변수

shareSnapshot

string

공유 스냅샷 타임스탬프입니다.

반환

새 ShareFileClient 개체는 원본과 동일하지만 지정된 공유 스냅샷 타임스탬프가 있습니다.