مشاركة عبر


DataLakeFileClient class

يمثل DataLakeFileClient عنوان URL لملف Azure Storage.

يمتد

المنشئون

DataLakeFileClient(string, Pipeline)

إنشاء مثيل DataLakeFileClient من عنوان URL والمسار.

DataLakeFileClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions)

إنشاء مثيل DataLakeFileClient من عنوان URL وبيانات الاعتماد.

الخصائص

fileSystemName

اسم نظام الملفات الحالي.

name

اسم المسار الحالي (دليل أو ملف).

الخصائص الموروثة

accountName
credential

مثل AnonymousCredential أو StorageSharedKeyCredential أو أي بيانات اعتماد من حزمة @azure/identity لمصادقة الطلبات إلى الخدمة. يمكنك أيضا توفير كائن ينفذ واجهة TokenCredential. إذا لم يتم تحديده، يتم استخدام AnonymousCredential.

url

قيمة سلسلة URL المرمزة.

الأساليب

append(RequestBodyType, number, number, FileAppendOptions)

تحميل البيانات ليتم إلحاقها إلى ملف. يمكن إلحاق البيانات فقط إلى ملف. لتطبيق البيانات التي تم تحميلها بشكل ضار على ملف، قم باستدعاء flush.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

create(FileCreateOptions)

إنشاء ملف.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

create(PathResourceType, PathCreateOptions)

إنشاء ملف.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

createIfNotExists(FileCreateIfNotExistsOptions)

إنشاء ملف إذا لم يكن موجودا بالفعل.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

createIfNotExists(PathResourceType, PathCreateIfNotExistsOptions)

إنشاء ملف إذا لم يكن موجودا بالفعل.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

flush(number, FileFlushOptions)

مسح (كتابة) البيانات التي تم إلحاقها مسبقا بالملف.

generateSasStringToSign(FileGenerateSasUrlOptions)

متوفر فقط للعملاء الذين تم إنشاؤهم باستخدام بيانات اعتماد مفتاح مشترك.

إنشاء سلسلة لتوقيع URI توقيع الوصول المشترك للخدمة (SAS) استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل.

راجع https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

generateSasUrl(FileGenerateSasUrlOptions)

متوفر فقط للعملاء الذين تم إنشاؤهم باستخدام بيانات اعتماد مفتاح مشترك.

إنشاء عنوان URI لتوقيع الوصول المشترك للخدمة (SAS) استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل.

راجع https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

generateUserDelegationSasStringToSign(FileGenerateSasUrlOptions, UserDelegationKey)

إنشاء سلسلة لتوقيع URI توقيع الوصول المشترك للخدمة (SAS) استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة مفتاح تفويض مستخدم الإدخال.

راجع https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

generateUserDelegationSasUrl(FileGenerateSasUrlOptions, UserDelegationKey)

إنشاء عنوان URI لتوقيع الوصول المشترك للخدمة (SAS) استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة مفتاح تفويض مستخدم الإدخال.

راجع https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

query(string, FileQueryOptions)

استعلام سريع لملف بتنسيق JSON أو CSV.

مثال على الاستخدام (Node.js):

import { DataLakeServiceClient } from "@azure/storage-file-datalake";

const account = "<account>";
const sas = "<sas token>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net${sas}`,
);

const fileSystemName = "<file system name>";
const fileName = "<file name>";
const fileSystemClient = datalakeServiceClient.getFileSystemClient(fileSystemName);
const fileClient = fileSystemClient.getFileClient(fileName);

// Query and convert a file to a string
const queryResponse = await fileClient.query("select * from BlobStorage");
if (queryResponse.readableStreamBody) {
  const responseBuffer = await streamToBuffer(queryResponse.readableStreamBody);
  const downloaded = responseBuffer.toString();
  console.log(`Query file content: ${downloaded}`);
}

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);
  });
}
read(number, number, FileReadOptions)

تنزيل ملف من الخدمة، بما في ذلك بيانات التعريف والخصائص الخاصة به.

  • في Node.js، ترجع البيانات في دفق قابل للقراءةStreamBody
  • في المستعرضات، ترجع البيانات في محتوى وعدAsBlob

راجع https://learn.microsoft.com/rest/api/storageservices/get-blob

  • مثال على الاستخدام (Node.js):
import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

const fileSystemName = "<file system name>";
const fileName = "<file name>";
const fileSystemClient = datalakeServiceClient.getFileSystemClient(fileSystemName);
const fileClient = fileSystemClient.getFileClient(fileName);

// Get file content from position 0 to the end
// In Node.js, get downloaded data by accessing downloadResponse.readableStreamBody
const downloadResponse = await fileClient.read();
if (downloadResponse.readableStreamBody) {
  const downloaded = await streamToBuffer(downloadResponse.readableStreamBody);
  console.log("Downloaded file content:", downloaded.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 { DataLakeServiceClient } from "@azure/storage-file-datalake";

const account = "<account>";
const sas = "<sas token>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net${sas}`,
);

const fileSystemName = "<file system name>";
const fileName = "<file name>";
const fileSystemClient = datalakeServiceClient.getFileSystemClient(fileSystemName);
const fileClient = fileSystemClient.getFileClient(fileName);

// Get file content from position 0 to the end
// In browsers, get downloaded data by accessing downloadResponse.contentAsBlob
const downloadResponse = await fileClient.read();
if (downloadResponse.contentAsBlob) {
  const blob = await downloadResponse.contentAsBlob;
  const downloaded = await blob.text();
  console.log(`Downloaded file content ${downloaded}`);
}
readToBuffer(Buffer, number, number, FileReadToBufferOptions)

متوفر فقط في وقت تشغيل NODE.JS.

يقرأ ملف Data Lake بالتوازي مع مخزن مؤقت. الإزاحة والعد اختيارية، مرر 0 لكليهما لقراءة الملف بأكمله.

تحذير: يمكن أن تدعم المخازن المؤقتة ملفات تصل إلى حوالي غيغابايت واحد فقط على أنظمة 32 بت أو حوالي غيغابايت على أنظمة 64 بت بسبب قيود Node.js/V8. بالنسبة للملفات الأكبر من هذا الحجم، ضع في اعتبارك readToFile.

readToBuffer(number, number, FileReadToBufferOptions)

متوفر فقط في وقت تشغيل NODE.JS

يقرأ ملف Data Lake بالتوازي مع مخزن مؤقت. الإزاحة والعد اختيارية، مرر 0 لكليهما لقراءة الملف بأكمله

تحذير: يمكن أن تدعم المخازن المؤقتة ملفات تصل إلى حوالي غيغابايت واحد فقط على أنظمة 32 بت أو حوالي غيغابايت على أنظمة 64 بت بسبب قيود Node.js/V8. بالنسبة للملفات الأكبر من هذا الحجم، ضع في اعتبارك readToFile.

readToFile(string, number, number, FileReadOptions)

متوفر فقط في وقت تشغيل NODE.JS.

تنزيل ملف Data Lake إلى ملف محلي. يفشل إذا تم إنهاء مسار الملف المحدد بالفعل. الإزاحة والعد اختيارية، وتمرير 0 وغير معرفة على التوالي لتنزيل الملف بأكمله.

setExpiry(PathExpiryOptions, FileSetExpiryOptions)

تعيين وقت انتهاء صلاحية على ملف، بمجرد استيفاء هذا الوقت يتم حذف الملف.

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

تحميل مخزن مؤقت(Node.js)/Blob/ArrayBuffer/ArrayBufferView إلى ملف.

uploadFile(string, FileParallelUploadOptions)

متوفر فقط في وقت تشغيل NODE.JS.

تحميل ملف محلي إلى ملف Data Lake.

uploadStream(Readable, FileParallelUploadOptions)

متوفر فقط في وقت تشغيل NODE.JS.

تحميل دفق Node.js قابل للقراءة في ملف Data Lake. سيحاول هذا الأسلوب إنشاء ملف، ثم يبدأ في تحميل جزء من مجموعة. يرجى التأكد من أن الحجم المحتمل للتدفق لا يتجاوز FILE_MAX_SIZE_BYTES وأن العدد المحتمل للتقسيمات لا يتجاوز BLOCK_BLOB_MAX_BLOCKS.

تلميحات تحسين الأداء:

  • تدفق الإدخال highWaterMark من الأفضل تعيين نفس القيمة مع المعلمة options.chunkSize، والتي ستتجنب عمليات Buffer.concat().

الأساليب المتوارثة

delete(boolean, PathDeleteOptions)

حذف المسار الحالي (دليل أو ملف).

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/delete

deleteIfExists(boolean, PathDeleteOptions)

حذف المسار الحالي (الدليل أو الملف) إذا كان موجودا.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/delete

exists(PathExistsOptions)

إرجاع true إذا كان ملف Data Lake الذي يمثله هذا العميل موجودا؛ خطأ خلاف ذلك.

ملاحظة: استخدم هذه الدالة بعناية حيث قد يتم حذف ملف موجود من قبل عملاء أو تطبيقات أخرى. قد تتم إضافة الملفات الجديدة بالعكس بواسطة عملاء أو تطبيقات أخرى بعد اكتمال هذه الدالة.

getAccessControl(PathGetAccessControlOptions)

إرجاع بيانات التحكم بالوصول لمسار (دليل الملف).

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/getproperties

getDataLakeLeaseClient(string)

احصل على DataLakeLeaseClient الذي يدير عقود الإيجار على المسار (الدليل أو الملف).

getProperties(PathGetPropertiesOptions)

إرجاع كافة بيانات التعريف المعرفة من قبل المستخدم وخصائص HTTP القياسية وخصائص النظام للمسار (الدليل أو الملف).

تحذير: سيكون للكائن metadata الذي تم إرجاعه في الاستجابة مفاتيحه بأحرف صغيرة، حتى لو احتوت في الأصل على أحرف كبيرة. يختلف هذا عن مفاتيح بيانات التعريف التي تم إرجاعها بواسطة أساليب DataLakeFileSystemClient التي تسرد المسارات باستخدام خيار includeMetadata، والتي ستحتفظ بأحرفها الأصلية.

راجع https://learn.microsoft.com/rest/api/storageservices/get-blob-properties

move(string, PathMoveOptions)

نقل الدليل أو الملف داخل نفس نظام الملفات.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

move(string, string, PathMoveOptions)

نقل الدليل أو الملف إلى نظام ملفات آخر.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

removeAccessControlRecursive(RemovePathAccessControlItem[], PathChangeAccessControlRecursiveOptions)

إزالة التحكم بالوصول على مسار ومسارات فرعية.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

setAccessControl(PathAccessControlItem[], PathSetAccessControlOptions)

تعيين بيانات التحكم في الوصول لمسار (دليل الملف).

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

setAccessControlRecursive(PathAccessControlItem[], PathChangeAccessControlRecursiveOptions)

تعيين Access Control على مسار ومسارات فرعية.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

setHttpHeaders(PathHttpHeaders, PathSetHttpHeadersOptions)

تعيين خصائص النظام على المسار (الدليل أو الملف).

إذا لم يتم توفير أي قيمة، أو لم يتم توفير قيمة لرؤوس كائن ثنائي كبير الحجم HTTP المحددة، مسح رؤوس HTTP للكائن الثنائي كبير الحجم هذه بدون قيمة.

راجع https://learn.microsoft.com/rest/api/storageservices/set-blob-properties

setMetadata(Metadata, PathSetMetadataOptions)

تعيين بيانات التعريف المعرفة من قبل المستخدم للمسار المحدد (دليل الملف) كزوج واحد أو أكثر من أزواج قيمة الاسم.

إذا لم يتم توفير أي خيار، أو لم يتم تحديد بيانات تعريف في المعلمة، فستتم إزالة بيانات تعريف المسار.

راجع https://learn.microsoft.com/rest/api/storageservices/set-blob-metadata

setPermissions(PathPermissions, PathSetPermissionsOptions)

تعيين أذونات الملف على مسار.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

toDirectoryClient()

تحويل DataLakePathClient الحالي إلى DataLakeDirectoryClient إذا كان المسار الحالي دليلا.

toFileClient()

تحويل DataLakePathClient الحالي إلى DataLakeFileClient إذا كان المسار الحالي ملفا.

updateAccessControlRecursive(PathAccessControlItem[], PathChangeAccessControlRecursiveOptions)

يعدل Access Control على مسار ومسارات فرعية.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

تفاصيل المنشئ

DataLakeFileClient(string, Pipeline)

إنشاء مثيل DataLakeFileClient من عنوان URL والمسار.

new DataLakeFileClient(url: string, pipeline: Pipeline)

المعلمات

url

string

سلسلة عميل تشير إلى ملف مستودع بيانات Azure Storage، مثل "https://myaccount.dfs.core.windows.net/filesystem/file". يمكنك إلحاق SAS إذا كنت تستخدم AnonymousCredential، مثل "https://myaccount.dfs.core.windows.net/filesystem/directory/file?sasString".

pipeline
Pipeline

استدعاء newPipeline() لإنشاء مسار افتراضي، أو توفير مسار مخصص.

DataLakeFileClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions)

إنشاء مثيل DataLakeFileClient من عنوان URL وبيانات الاعتماد.

new DataLakeFileClient(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)

المعلمات

url

string

سلسلة عميل تشير إلى ملف مستودع بيانات Azure Storage، مثل "https://myaccount.dfs.core.windows.net/filesystem/file". يمكنك إلحاق SAS إذا كنت تستخدم AnonymousCredential، مثل "https://myaccount.dfs.core.windows.net/filesystem/directory/file?sasString".

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

مثل AnonymousCredential أو StorageSharedKeyCredential أو أي بيانات اعتماد من حزمة @azure/identity لمصادقة الطلبات إلى الخدمة. يمكنك أيضا توفير كائن ينفذ واجهة TokenCredential. إذا لم يتم تحديده، يتم استخدام AnonymousCredential.

options
StoragePipelineOptions

Optional. خيارات لتكوين البنية الأساسية لبرنامج ربط العمليات التجارية HTTP.

تفاصيل الخاصية

fileSystemName

اسم نظام الملفات الحالي.

string fileSystemName

قيمة الخاصية

string

name

اسم المسار الحالي (دليل أو ملف).

string name

قيمة الخاصية

string

تفاصيل الخاصية الموروثة

accountName

accountName: string

قيمة الخاصية

string

موروثة منDataLakePathClient.accountName

credential

مثل AnonymousCredential أو StorageSharedKeyCredential أو أي بيانات اعتماد من حزمة @azure/identity لمصادقة الطلبات إلى الخدمة. يمكنك أيضا توفير كائن ينفذ واجهة TokenCredential. إذا لم يتم تحديده، يتم استخدام AnonymousCredential.

credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential

قيمة الخاصية

موروثة منDataLakePathClient.credential

url

قيمة سلسلة URL المرمزة.

url: string

قيمة الخاصية

string

موروثة منDataLakePathClient.url

تفاصيل الأسلوب

append(RequestBodyType, number, number, FileAppendOptions)

تحميل البيانات ليتم إلحاقها إلى ملف. يمكن إلحاق البيانات فقط إلى ملف. لتطبيق البيانات التي تم تحميلها بشكل ضار على ملف، قم باستدعاء flush.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

function append(body: RequestBodyType, offset: number, length: number, options?: FileAppendOptions): Promise<FileAppendResponse>

المعلمات

body
HttpRequestBody

المحتوى المطلوب تحميله.

offset

number

إلحاق الإزاحة بالبايت.

length

number

طول المحتوى المراد إلحاقه بالبايت.

options
FileAppendOptions

Optional. الخيارات عند إلحاق البيانات.

المرتجعات

create(FileCreateOptions)

إنشاء ملف.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

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

المعلمات

options
FileCreateOptions

Optional. الخيارات عند إنشاء ملف.

المرتجعات

create(PathResourceType, PathCreateOptions)

إنشاء ملف.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

function create(resourceType: PathResourceType, options?: PathCreateOptions): Promise<PathCreateResponse>

المعلمات

resourceType
PathResourceTypeModel

يجب أن يكون نوع المورد "ملف" ل DataLakeFileClient.

options
PathCreateOptions

Optional. الخيارات عند إنشاء ملف.

المرتجعات

createIfNotExists(FileCreateIfNotExistsOptions)

إنشاء ملف إذا لم يكن موجودا بالفعل.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

function createIfNotExists(options?: FileCreateIfNotExistsOptions): Promise<FileCreateIfNotExistsResponse>

المعلمات

options
FileCreateIfNotExistsOptions

Optional. الخيارات عند إنشاء ملف.

المرتجعات

createIfNotExists(PathResourceType, PathCreateIfNotExistsOptions)

إنشاء ملف إذا لم يكن موجودا بالفعل.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

function createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise<PathCreateIfNotExistsResponse>

المعلمات

resourceType
PathResourceTypeModel

يجب أن يكون نوع المورد "ملف" ل DataLakeFileClient.

المرتجعات

flush(number, FileFlushOptions)

مسح (كتابة) البيانات التي تم إلحاقها مسبقا بالملف.

function flush(position: number, options?: FileFlushOptions): Promise<FileFlushResponse>

المعلمات

position

number

موضع الملف المراد مسحه. تسمح هذه المعلمة للمتصل بتحميل البيانات بالتوازي والتحكم في الترتيب الذي يتم إلحاقها به بالملف. وهو مطلوب عند تحميل البيانات ليتم إلحاقها بالملف وعند مسح البيانات التي تم تحميلها مسبقا إلى الملف. يجب أن تكون القيمة هي الموضع الذي يجب إلحاق البيانات فيه. لا يتم مسح البيانات التي تم تحميلها على الفور، أو كتابتها، إلى الملف. للمسح، يجب أن تكون البيانات التي تم تحميلها مسبقا متقاربة، ويجب تحديد معلمة الموضع وتساوي طول الملف بعد كتابة جميع البيانات، ويجب ألا يكون هناك نص كيان طلب مضمن مع الطلب.

options
FileFlushOptions

Optional. الخيارات عند مسح البيانات.

المرتجعات

generateSasStringToSign(FileGenerateSasUrlOptions)

متوفر فقط للعملاء الذين تم إنشاؤهم باستخدام بيانات اعتماد مفتاح مشترك.

إنشاء سلسلة لتوقيع URI توقيع الوصول المشترك للخدمة (SAS) استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل.

راجع https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

function generateSasStringToSign(options: FileGenerateSasUrlOptions): string

المعلمات

options
FileGenerateSasUrlOptions

المعلمات الاختيارية.

المرتجعات

string

SAS URI الذي يتكون من URI للمورد الذي يمثله هذا العميل، متبوعا بالرمز المميز SAS الذي تم إنشاؤه.

generateSasUrl(FileGenerateSasUrlOptions)

متوفر فقط للعملاء الذين تم إنشاؤهم باستخدام بيانات اعتماد مفتاح مشترك.

إنشاء عنوان URI لتوقيع الوصول المشترك للخدمة (SAS) استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل.

راجع https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

function generateSasUrl(options: FileGenerateSasUrlOptions): Promise<string>

المعلمات

options
FileGenerateSasUrlOptions

المعلمات الاختيارية.

المرتجعات

Promise<string>

SAS URI الذي يتكون من URI للمورد الذي يمثله هذا العميل، متبوعا بالرمز المميز SAS الذي تم إنشاؤه.

generateUserDelegationSasStringToSign(FileGenerateSasUrlOptions, UserDelegationKey)

إنشاء سلسلة لتوقيع URI توقيع الوصول المشترك للخدمة (SAS) استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة مفتاح تفويض مستخدم الإدخال.

راجع https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

function generateUserDelegationSasStringToSign(options: FileGenerateSasUrlOptions, userDelegationKey: UserDelegationKey): string

المعلمات

options
FileGenerateSasUrlOptions

المعلمات الاختيارية.

userDelegationKey
UserDelegationKey

القيمة المرجعة blobServiceClient.getUserDelegationKey()

المرتجعات

string

SAS URI الذي يتكون من URI للمورد الذي يمثله هذا العميل، متبوعا بالرمز المميز SAS الذي تم إنشاؤه.

generateUserDelegationSasUrl(FileGenerateSasUrlOptions, UserDelegationKey)

إنشاء عنوان URI لتوقيع الوصول المشترك للخدمة (SAS) استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة مفتاح تفويض مستخدم الإدخال.

راجع https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas

function generateUserDelegationSasUrl(options: FileGenerateSasUrlOptions, userDelegationKey: UserDelegationKey): Promise<string>

المعلمات

options
FileGenerateSasUrlOptions

المعلمات الاختيارية.

userDelegationKey
UserDelegationKey

القيمة المرجعة blobServiceClient.getUserDelegationKey()

المرتجعات

Promise<string>

SAS URI الذي يتكون من URI للمورد الذي يمثله هذا العميل، متبوعا بالرمز المميز SAS الذي تم إنشاؤه.

query(string, FileQueryOptions)

استعلام سريع لملف بتنسيق JSON أو CSV.

مثال على الاستخدام (Node.js):

import { DataLakeServiceClient } from "@azure/storage-file-datalake";

const account = "<account>";
const sas = "<sas token>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net${sas}`,
);

const fileSystemName = "<file system name>";
const fileName = "<file name>";
const fileSystemClient = datalakeServiceClient.getFileSystemClient(fileSystemName);
const fileClient = fileSystemClient.getFileClient(fileName);

// Query and convert a file to a string
const queryResponse = await fileClient.query("select * from BlobStorage");
if (queryResponse.readableStreamBody) {
  const responseBuffer = await streamToBuffer(queryResponse.readableStreamBody);
  const downloaded = responseBuffer.toString();
  console.log(`Query file content: ${downloaded}`);
}

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);
  });
}
function query(query: string, options?: FileQueryOptions): Promise<FileReadResponse>

المعلمات

query

string

المرتجعات

Promise<FileReadResponse>

read(number, number, FileReadOptions)

تنزيل ملف من الخدمة، بما في ذلك بيانات التعريف والخصائص الخاصة به.

  • في Node.js، ترجع البيانات في دفق قابل للقراءةStreamBody
  • في المستعرضات، ترجع البيانات في محتوى وعدAsBlob

راجع https://learn.microsoft.com/rest/api/storageservices/get-blob

  • مثال على الاستخدام (Node.js):
import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

const fileSystemName = "<file system name>";
const fileName = "<file name>";
const fileSystemClient = datalakeServiceClient.getFileSystemClient(fileSystemName);
const fileClient = fileSystemClient.getFileClient(fileName);

// Get file content from position 0 to the end
// In Node.js, get downloaded data by accessing downloadResponse.readableStreamBody
const downloadResponse = await fileClient.read();
if (downloadResponse.readableStreamBody) {
  const downloaded = await streamToBuffer(downloadResponse.readableStreamBody);
  console.log("Downloaded file content:", downloaded.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 { DataLakeServiceClient } from "@azure/storage-file-datalake";

const account = "<account>";
const sas = "<sas token>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net${sas}`,
);

const fileSystemName = "<file system name>";
const fileName = "<file name>";
const fileSystemClient = datalakeServiceClient.getFileSystemClient(fileSystemName);
const fileClient = fileSystemClient.getFileClient(fileName);

// Get file content from position 0 to the end
// In browsers, get downloaded data by accessing downloadResponse.contentAsBlob
const downloadResponse = await fileClient.read();
if (downloadResponse.contentAsBlob) {
  const blob = await downloadResponse.contentAsBlob;
  const downloaded = await blob.text();
  console.log(`Downloaded file content ${downloaded}`);
}
function read(offset?: number, count?: number, options?: FileReadOptions): Promise<FileReadResponse>

المعلمات

offset

number

Optional. إزاحة لقراءة الملف، القيمة الافتراضية هي 0.

count

number

Optional. كم عدد وحدات البايت المراد قراءتها، سيتم قراءة الإعداد الافتراضي من الإزاحة إلى النهاية.

options
FileReadOptions

Optional. الخيارات عند قراءة الملف.

المرتجعات

Promise<FileReadResponse>

readToBuffer(Buffer, number, number, FileReadToBufferOptions)

متوفر فقط في وقت تشغيل NODE.JS.

يقرأ ملف Data Lake بالتوازي مع مخزن مؤقت. الإزاحة والعد اختيارية، مرر 0 لكليهما لقراءة الملف بأكمله.

تحذير: يمكن أن تدعم المخازن المؤقتة ملفات تصل إلى حوالي غيغابايت واحد فقط على أنظمة 32 بت أو حوالي غيغابايت على أنظمة 64 بت بسبب قيود Node.js/V8. بالنسبة للملفات الأكبر من هذا الحجم، ضع في اعتبارك readToFile.

function readToBuffer(buffer: Buffer, offset?: number, count?: number, options?: FileReadToBufferOptions): Promise<Buffer>

المعلمات

buffer

Buffer

المخزن المؤقت المطلوب تعبئته، يجب أن يكون طوله أكبر من العدد

offset

number

من أي موضع من ملف Data Lake للقراءة

count

number

مقدار البيانات التي يجب قراءتها. سيقرأ إلى النهاية عند تمرير غير معرف

المرتجعات

Promise<Buffer>

readToBuffer(number, number, FileReadToBufferOptions)

متوفر فقط في وقت تشغيل NODE.JS

يقرأ ملف Data Lake بالتوازي مع مخزن مؤقت. الإزاحة والعد اختيارية، مرر 0 لكليهما لقراءة الملف بأكمله

تحذير: يمكن أن تدعم المخازن المؤقتة ملفات تصل إلى حوالي غيغابايت واحد فقط على أنظمة 32 بت أو حوالي غيغابايت على أنظمة 64 بت بسبب قيود Node.js/V8. بالنسبة للملفات الأكبر من هذا الحجم، ضع في اعتبارك readToFile.

function readToBuffer(offset?: number, count?: number, options?: FileReadToBufferOptions): Promise<Buffer>

المعلمات

offset

number

من أي موضع من ملف Data Lake للقراءة (بالبايت)

count

number

مقدار البيانات (بالبايت) المراد قراءتها. سيقرأ إلى النهاية عند تمرير غير معرف

المرتجعات

Promise<Buffer>

readToFile(string, number, number, FileReadOptions)

متوفر فقط في وقت تشغيل NODE.JS.

تنزيل ملف Data Lake إلى ملف محلي. يفشل إذا تم إنهاء مسار الملف المحدد بالفعل. الإزاحة والعد اختيارية، وتمرير 0 وغير معرفة على التوالي لتنزيل الملف بأكمله.

function readToFile(filePath: string, offset?: number, count?: number, options?: FileReadOptions): Promise<FileReadResponse>

المعلمات

filePath

string

offset

number

من أي موضع من الملف المراد تنزيله.

count

number

مقدار البيانات التي سيتم تنزيلها. سيتم التنزيل إلى النهاية عند تمرير غير معرف.

options
FileReadOptions

خيارات لقراءة ملف Data Lake.

المرتجعات

Promise<FileReadResponse>

بيانات الاستجابة لعملية قراءة الملف، ولكن مع تعيين readableStreamBody إلى غير معرف لأن محتواه تمت قراءته بالفعل وكتابته في ملف محلي في المسار المحدد.

setExpiry(PathExpiryOptions, FileSetExpiryOptions)

تعيين وقت انتهاء صلاحية على ملف، بمجرد استيفاء هذا الوقت يتم حذف الملف.

function setExpiry(mode: PathExpiryOptions, options?: FileSetExpiryOptions): Promise<FileSetExpiryResponse>

المعلمات

المرتجعات

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

تحميل مخزن مؤقت(Node.js)/Blob/ArrayBuffer/ArrayBufferView إلى ملف.

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

المعلمات

data

Blob | ArrayBuffer | ArrayBufferView | Buffer

المخزن المؤقت (العقدة) أو Blob أو ArrayBuffer أو ArrayBufferView

المرتجعات

uploadFile(string, FileParallelUploadOptions)

متوفر فقط في وقت تشغيل NODE.JS.

تحميل ملف محلي إلى ملف Data Lake.

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

المعلمات

filePath

string

المسار الكامل للملف المحلي

المرتجعات

uploadStream(Readable, FileParallelUploadOptions)

متوفر فقط في وقت تشغيل NODE.JS.

تحميل دفق Node.js قابل للقراءة في ملف Data Lake. سيحاول هذا الأسلوب إنشاء ملف، ثم يبدأ في تحميل جزء من مجموعة. يرجى التأكد من أن الحجم المحتمل للتدفق لا يتجاوز FILE_MAX_SIZE_BYTES وأن العدد المحتمل للتقسيمات لا يتجاوز BLOCK_BLOB_MAX_BLOCKS.

تلميحات تحسين الأداء:

  • تدفق الإدخال highWaterMark من الأفضل تعيين نفس القيمة مع المعلمة options.chunkSize، والتي ستتجنب عمليات Buffer.concat().
function uploadStream(stream: Readable, options?: FileParallelUploadOptions): Promise<FileUploadResponse>

المعلمات

stream

Readable

Node.js دفق قابل للقراءة.

المرتجعات

تفاصيل الأساليب المتوارثة

delete(boolean, PathDeleteOptions)

حذف المسار الحالي (دليل أو ملف).

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/delete

function delete(recursive?: boolean, options?: PathDeleteOptions): Promise<PathDeleteResponse>

المعلمات

recursive

boolean

مطلوب وصالح فقط عندما يكون المورد دليلا. إذا كانت "true"، حذف كافة المسارات الموجودة أسفل الدليل.

options
PathDeleteOptions

Optional. خيارات عند حذف المسار.

المرتجعات

موروثة منDataLakePathClient.delete

deleteIfExists(boolean, PathDeleteOptions)

حذف المسار الحالي (الدليل أو الملف) إذا كان موجودا.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/delete

function deleteIfExists(recursive?: boolean, options?: PathDeleteOptions): Promise<PathDeleteIfExistsResponse>

المعلمات

recursive

boolean

مطلوب وصالح فقط عندما يكون المورد دليلا. إذا كانت "true"، حذف كافة المسارات الموجودة أسفل الدليل.

المرتجعات

موروثة منDataLakePathClient.deleteIfExists

exists(PathExistsOptions)

إرجاع true إذا كان ملف Data Lake الذي يمثله هذا العميل موجودا؛ خطأ خلاف ذلك.

ملاحظة: استخدم هذه الدالة بعناية حيث قد يتم حذف ملف موجود من قبل عملاء أو تطبيقات أخرى. قد تتم إضافة الملفات الجديدة بالعكس بواسطة عملاء أو تطبيقات أخرى بعد اكتمال هذه الدالة.

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

المعلمات

options
PathExistsOptions

خيارات لعملية Exists.

المرتجعات

Promise<boolean>

موروثة منDataLakePathClient.exists

getAccessControl(PathGetAccessControlOptions)

إرجاع بيانات التحكم بالوصول لمسار (دليل الملف).

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/getproperties

function getAccessControl(options?: PathGetAccessControlOptions): Promise<PathGetAccessControlResponse>

المعلمات

options
PathGetAccessControlOptions

Optional. الخيارات عند الحصول على التحكم في الوصول إلى الملفات.

المرتجعات

موروثة منDataLakePathClient.getAccessControl

getDataLakeLeaseClient(string)

احصل على DataLakeLeaseClient الذي يدير عقود الإيجار على المسار (الدليل أو الملف).

function getDataLakeLeaseClient(proposeLeaseId?: string): DataLakeLeaseClient

المعلمات

proposeLeaseId

string

Optional. معرف التأجير المقترح الأولي.

المرتجعات

موروث منDataLakePathClient.getDataLakeLeaseClient

getProperties(PathGetPropertiesOptions)

إرجاع كافة بيانات التعريف المعرفة من قبل المستخدم وخصائص HTTP القياسية وخصائص النظام للمسار (الدليل أو الملف).

تحذير: سيكون للكائن metadata الذي تم إرجاعه في الاستجابة مفاتيحه بأحرف صغيرة، حتى لو احتوت في الأصل على أحرف كبيرة. يختلف هذا عن مفاتيح بيانات التعريف التي تم إرجاعها بواسطة أساليب DataLakeFileSystemClient التي تسرد المسارات باستخدام خيار includeMetadata، والتي ستحتفظ بأحرفها الأصلية.

راجع https://learn.microsoft.com/rest/api/storageservices/get-blob-properties

function getProperties(options?: PathGetPropertiesOptions): Promise<PathGetPropertiesResponse>

المعلمات

options
PathGetPropertiesOptions

Optional. الخيارات عند الحصول على خصائص المسار.

المرتجعات

موروثة منDataLakePathClient.getProperties

move(string, PathMoveOptions)

نقل الدليل أو الملف داخل نفس نظام الملفات.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

function move(destinationPath: string, options?: PathMoveOptions): Promise<PathMoveResponse>

المعلمات

destinationPath

string

مسار الدليل الوجهة مثل "الدليل" أو مسار الملف "الدليل/الملف". إذا تمت مصادقة destinationPath باستخدام SAS، أضف SAS إلى مسار الوجهة مثل "directory/file?sasToken".

options
PathMoveOptions

Optional. خيارات عند نقل الدليل أو الملف.

المرتجعات

Promise<PathMoveResponse>

موروثة منDataLakePathClient.move

move(string, string, PathMoveOptions)

نقل الدليل أو الملف إلى نظام ملفات آخر.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/create

function move(destinationFileSystem: string, destinationPath: string, options?: PathMoveOptions): Promise<PathMoveResponse>

المعلمات

destinationFileSystem

string

نظام الملفات الوجهة مثل "نظام الملفات".

destinationPath

string

مسار الدليل الوجهة مثل "الدليل" أو مسار الملف "الدليل/الملف" إذا تمت مصادقة destinationPath باستخدام SAS، أضف SAS إلى مسار الوجهة مثل "directory/file?sasToken".

options
PathMoveOptions

Optional. خيارات عند نقل الدليل أو الملف.

المرتجعات

Promise<PathMoveResponse>

موروثة منDataLakePathClient.move

removeAccessControlRecursive(RemovePathAccessControlItem[], PathChangeAccessControlRecursiveOptions)

إزالة التحكم بالوصول على مسار ومسارات فرعية.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

function removeAccessControlRecursive(acl: RemovePathAccessControlItem[], options?: PathChangeAccessControlRecursiveOptions): Promise<PathChangeAccessControlRecursiveResponse>

المعلمات

acl

RemovePathAccessControlItem[]

قائمة التحكم بالوصول إلى POSIX للملف أو الدليل.

options
PathChangeAccessControlRecursiveOptions

Optional. Options

المرتجعات

موروثة منDataLakePathClient.removeAccessControlRecursive

setAccessControl(PathAccessControlItem[], PathSetAccessControlOptions)

تعيين بيانات التحكم في الوصول لمسار (دليل الملف).

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

function setAccessControl(acl: PathAccessControlItem[], options?: PathSetAccessControlOptions): Promise<PathSetAccessControlResponse>

المعلمات

acl

PathAccessControlItem[]

قائمة التحكم بالوصول إلى POSIX للملف أو الدليل.

options
PathSetAccessControlOptions

Optional. الخيارات عند تعيين التحكم في الوصول إلى المسار.

المرتجعات

موروثة منDataLakePathClient.setAccessControl

setAccessControlRecursive(PathAccessControlItem[], PathChangeAccessControlRecursiveOptions)

تعيين Access Control على مسار ومسارات فرعية.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

function setAccessControlRecursive(acl: PathAccessControlItem[], options?: PathChangeAccessControlRecursiveOptions): Promise<PathChangeAccessControlRecursiveResponse>

المعلمات

acl

PathAccessControlItem[]

قائمة التحكم بالوصول إلى POSIX للملف أو الدليل.

options
PathChangeAccessControlRecursiveOptions

Optional. Options

المرتجعات

موروثة منDataLakePathClient.setAccessControlRecursive

setHttpHeaders(PathHttpHeaders, PathSetHttpHeadersOptions)

تعيين خصائص النظام على المسار (الدليل أو الملف).

إذا لم يتم توفير أي قيمة، أو لم يتم توفير قيمة لرؤوس كائن ثنائي كبير الحجم HTTP المحددة، مسح رؤوس HTTP للكائن الثنائي كبير الحجم هذه بدون قيمة.

راجع https://learn.microsoft.com/rest/api/storageservices/set-blob-properties

function setHttpHeaders(httpHeaders: PathHttpHeaders, options?: PathSetHttpHeadersOptions): Promise<PathSetHttpHeadersResponse>

المعلمات

httpHeaders
PathHttpHeaders

المرتجعات

موروثة منDataLakePathClient.setHttpHeaders

setMetadata(Metadata, PathSetMetadataOptions)

تعيين بيانات التعريف المعرفة من قبل المستخدم للمسار المحدد (دليل الملف) كزوج واحد أو أكثر من أزواج قيمة الاسم.

إذا لم يتم توفير أي خيار، أو لم يتم تحديد بيانات تعريف في المعلمة، فستتم إزالة بيانات تعريف المسار.

راجع https://learn.microsoft.com/rest/api/storageservices/set-blob-metadata

function setMetadata(metadata?: Metadata, options?: PathSetMetadataOptions): Promise<PathSetMetadataResponse>

المعلمات

metadata
Metadata

Optional. استبدل بيانات التعريف الموجودة بهذه القيمة. إذا لم يتم توفير أي قيمة، فستتم إزالة بيانات التعريف الموجودة.

options
PathSetMetadataOptions

Optional. خيارات عند تعيين بيانات تعريف المسار.

المرتجعات

موروثة منDataLakePathClient.setMetadata

setPermissions(PathPermissions, PathSetPermissionsOptions)

تعيين أذونات الملف على مسار.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

function setPermissions(permissions: PathPermissions, options?: PathSetPermissionsOptions): Promise<PathSetPermissionsResponse>

المعلمات

permissions
PathPermissions

أذونات الوصول إلى POSIX لمالك الملف ومجموعة امتلاك الملف وغيرها.

options
PathSetPermissionsOptions

Optional. الخيارات عند تعيين أذونات المسار.

المرتجعات

موروثة منDataLakePathClient.setPermissions

toDirectoryClient()

تحويل DataLakePathClient الحالي إلى DataLakeDirectoryClient إذا كان المسار الحالي دليلا.

function toDirectoryClient(): DataLakeDirectoryClient

المرتجعات

موروثة منDataLakePathClient.toDirectoryClient

toFileClient()

تحويل DataLakePathClient الحالي إلى DataLakeFileClient إذا كان المسار الحالي ملفا.

function toFileClient(): DataLakeFileClient

المرتجعات

موروثة منDataLakePathClient.toFileClient

updateAccessControlRecursive(PathAccessControlItem[], PathChangeAccessControlRecursiveOptions)

يعدل Access Control على مسار ومسارات فرعية.

راجع https://learn.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/update

function updateAccessControlRecursive(acl: PathAccessControlItem[], options?: PathChangeAccessControlRecursiveOptions): Promise<PathChangeAccessControlRecursiveResponse>

المعلمات

acl

PathAccessControlItem[]

قائمة التحكم بالوصول إلى POSIX للملف أو الدليل.

options
PathChangeAccessControlRecursiveOptions

Optional. Options

المرتجعات

موروثة منDataLakePathClient.updateAccessControlRecursive