Share via


Core.CreateAsync Method

Definition

Create a new file. This is an asynchronous operation.

Not threadsafe when CreateAsync is called multiple times for same path with different leaseId.

public static System.Threading.Tasks.Task CreateAsync (string path, bool overwrite, string octalPermission, string leaseId, string sessionId, bool createParent, Microsoft.Azure.DataLake.Store.SyncFlag flag, byte[] dataBytes, int offset, int length, Microsoft.Azure.DataLake.Store.AdlsClient client, Microsoft.Azure.DataLake.Store.RequestOptions req, Microsoft.Azure.DataLake.Store.OperationResponse resp, System.Threading.CancellationToken cancelToken = default);
static member CreateAsync : string * bool * string * string * string * bool * Microsoft.Azure.DataLake.Store.SyncFlag * byte[] * int * int * Microsoft.Azure.DataLake.Store.AdlsClient * Microsoft.Azure.DataLake.Store.RequestOptions * Microsoft.Azure.DataLake.Store.OperationResponse * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function CreateAsync (path As String, overwrite As Boolean, octalPermission As String, leaseId As String, sessionId As String, createParent As Boolean, flag As SyncFlag, dataBytes As Byte(), offset As Integer, length As Integer, client As AdlsClient, req As RequestOptions, resp As OperationResponse, Optional cancelToken As CancellationToken = Nothing) As Task

Parameters

path
String

Path of the file

overwrite
Boolean

Overwrites the existing file if the flag is true

octalPermission
String

Octal permission string

leaseId
String

String containing the lease ID, when a client obtains a lease on a file no other client can make edits to the file

sessionId
String

UUID that is used to obtain the file handler (stream) easily at server

createParent
Boolean

If true creates any non-existing parent directories

flag
SyncFlag

Pass SyncFlag.DATA when writing bytes of data Pass SyncFlag.METADATA when metadata of the file like length, modified instant needs to be updated to be consistent with the actual data of file. After passing SyncFlag.METADATA GetFileStatus and ListStatus returns consistent data. Pass SyncFlag.CLOSE when no more data needs to be appended, file metadata is updated, lease is released and the stream is closed

dataBytes
Byte[]

Array of bytes to write to the file

offset
Int32

Offset in the byte array

length
Int32

Number of bytes to write from the offset

client
AdlsClient

ADLS Client

req
RequestOptions

Options to change behavior of the Http request

resp
OperationResponse

Stores the response/ouput of the Http request

cancelToken
CancellationToken

CancellationToken to cancel the request

Returns

Applies to